[Java] Update auto-generated Java bindings
[ldk-java] / src / main / jni / bindings.c.body
1 #include <jni.h>
2 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
3 #define int64_t jlong
4 #include "org_ldk_impl_bindings.h"
5 #include <lightning.h>
6 #include <string.h>
7 #include <stdatomic.h>
8 #include <stdlib.h>
9
10 #define LIKELY(v) __builtin_expect(!!(v), 1)
11 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
12
13 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
14 #define MALLOC(a, _) malloc(a)
15 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
16 #define CHECK_ACCESS(p)
17 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
18 #define DO_ASSERT(a) (void)(a)
19 #define CHECK(a)
20
21 static jmethodID ordinal_meth = NULL;
22 static jmethodID slicedef_meth = NULL;
23 static jclass slicedef_cls = NULL;
24 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
25         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
26         CHECK(ordinal_meth != NULL);
27         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
28         CHECK(slicedef_meth != NULL);
29         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
30         CHECK(slicedef_cls != NULL);
31 }
32
33 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
34         return *((bool*)ptr);
35 }
36 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
37         return *((long*)ptr);
38 }
39 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
40         FREE((void*)ptr);
41 }
42 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
43         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
44         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
45         return ret_arr;
46 }
47 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
48         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
49         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
50         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
51         return ret_arr;
52 }
53 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
54         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
55         vec->datalen = (*env)->GetArrayLength(env, bytes);
56         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
57         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
58         return (uint64_t)vec;
59 }
60 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
61         LDKTransaction *txdata = (LDKTransaction*)ptr;
62         LDKu8slice slice;
63         slice.data = txdata->data;
64         slice.datalen = txdata->datalen;
65         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
66 }
67 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
68         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
69         txdata->datalen = (*env)->GetArrayLength(env, bytes);
70         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
71         txdata->data_is_owned = false;
72         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
73         return (uint64_t)txdata;
74 }
75 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
76         LDKTransaction *tx = (LDKTransaction*)ptr;
77         tx->data_is_owned = true;
78         Transaction_free(*tx);
79         FREE((void*)ptr);
80 }
81 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
82         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
83         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
84         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
85         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
86         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
87         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
88         return (uint64_t)vec->datalen;
89 }
90 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
91         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
92         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
93         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
94         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
95         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
96         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
97         vec->data = NULL;
98         vec->datalen = 0;
99         return (uint64_t)vec;
100 }
101
102 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
103 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
104 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
105 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
106
107 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
108 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
109 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
110
111 typedef jlongArray int64_tArray;
112 typedef jbyteArray int8_tArray;
113
114 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
115         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
116         char* conv_buf = MALLOC(len + 1, "str conv buf");
117         memcpy(conv_buf, chars, len);
118         conv_buf[len] = 0;
119         jstring ret = (*env)->NewStringUTF(env, conv_buf);
120         FREE(conv_buf);
121         return ret;
122 }
123 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
124         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
125         char* newchars = MALLOC(str_len + 1, "String chars");
126         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
127         memcpy(newchars, jchars, str_len);
128         newchars[str_len] = 0;
129         (*env)->ReleaseStringUTFChars(env, str, jchars);
130         LDKStr res = {
131                 .chars = newchars,
132                 .len = str_len,
133                 .chars_is_owned = true
134         };
135         return res;
136 }
137
138 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
139         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
140 }
141 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
142         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
143 }
144 #include "version.c"
145 static jclass arr_of_B_clz = NULL;
146 static jclass arr_of_J_clz = NULL;
147 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
148         arr_of_B_clz = (*env)->FindClass(env, "[B");
149         CHECK(arr_of_B_clz != NULL);
150         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
151         arr_of_J_clz = (*env)->FindClass(env, "[J");
152         CHECK(arr_of_J_clz != NULL);
153         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
154 }
155 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
156 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
157         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
158         if (UNLIKELY((*env)->ExceptionCheck(env))) {
159                 (*env)->ExceptionDescribe(env);
160                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
161         }
162         switch (ord) {
163                 case 0: return LDKAccessError_UnknownChain;
164                 case 1: return LDKAccessError_UnknownTx;
165         }
166         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
167         abort(); // Unreachable, but will let the compiler know we don't return here
168 }
169 static jclass AccessError_class = NULL;
170 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
171 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
172 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
173         AccessError_class = (*env)->NewGlobalRef(env, clz);
174         CHECK(AccessError_class != NULL);
175         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
176         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
177         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
178         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
179 }
180 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
181         switch (val) {
182                 case LDKAccessError_UnknownChain:
183                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
184                 case LDKAccessError_UnknownTx:
185                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
186                 default: abort();
187         }
188 }
189
190 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
191         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
192         if (UNLIKELY((*env)->ExceptionCheck(env))) {
193                 (*env)->ExceptionDescribe(env);
194                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
195         }
196         switch (ord) {
197                 case 0: return LDKCOption_NoneZ_Some;
198                 case 1: return LDKCOption_NoneZ_None;
199         }
200         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
201         abort(); // Unreachable, but will let the compiler know we don't return here
202 }
203 static jclass COption_NoneZ_class = NULL;
204 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
205 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
206 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
207         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
208         CHECK(COption_NoneZ_class != NULL);
209         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
210         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
211         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
212         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
213 }
214 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
215         switch (val) {
216                 case LDKCOption_NoneZ_Some:
217                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
218                 case LDKCOption_NoneZ_None:
219                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
220                 default: abort();
221         }
222 }
223
224 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
225         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
226         if (UNLIKELY((*env)->ExceptionCheck(env))) {
227                 (*env)->ExceptionDescribe(env);
228                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust threw an exception.");
229         }
230         switch (ord) {
231                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
232                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
233         }
234         (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust returned an invalid value.");
235         abort(); // Unreachable, but will let the compiler know we don't return here
236 }
237 static jclass ChannelMonitorUpdateErr_class = NULL;
238 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
239 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
240 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
241         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
242         CHECK(ChannelMonitorUpdateErr_class != NULL);
243         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
244         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
245         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
246         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
247 }
248 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
249         switch (val) {
250                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
251                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
252                 case LDKChannelMonitorUpdateErr_PermanentFailure:
253                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
254                 default: abort();
255         }
256 }
257
258 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
259         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
260         if (UNLIKELY((*env)->ExceptionCheck(env))) {
261                 (*env)->ExceptionDescribe(env);
262                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
263         }
264         switch (ord) {
265                 case 0: return LDKConfirmationTarget_Background;
266                 case 1: return LDKConfirmationTarget_Normal;
267                 case 2: return LDKConfirmationTarget_HighPriority;
268         }
269         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
270         abort(); // Unreachable, but will let the compiler know we don't return here
271 }
272 static jclass ConfirmationTarget_class = NULL;
273 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
274 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
275 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
276 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
277         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
278         CHECK(ConfirmationTarget_class != NULL);
279         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
280         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
281         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
282         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
283         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
284         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
285 }
286 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
287         switch (val) {
288                 case LDKConfirmationTarget_Background:
289                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
290                 case LDKConfirmationTarget_Normal:
291                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
292                 case LDKConfirmationTarget_HighPriority:
293                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
294                 default: abort();
295         }
296 }
297
298 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
299         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
300         if (UNLIKELY((*env)->ExceptionCheck(env))) {
301                 (*env)->ExceptionDescribe(env);
302                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
303         }
304         switch (ord) {
305                 case 0: return LDKCreationError_DescriptionTooLong;
306                 case 1: return LDKCreationError_RouteTooLong;
307                 case 2: return LDKCreationError_TimestampOutOfBounds;
308                 case 3: return LDKCreationError_InvalidAmount;
309                 case 4: return LDKCreationError_MissingRouteHints;
310         }
311         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
312         abort(); // Unreachable, but will let the compiler know we don't return here
313 }
314 static jclass CreationError_class = NULL;
315 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
316 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
317 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
318 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
319 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
320 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
321         CreationError_class = (*env)->NewGlobalRef(env, clz);
322         CHECK(CreationError_class != NULL);
323         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
324         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
325         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
326         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
327         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
328         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
329         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
330         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
331         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
332         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
333 }
334 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
335         switch (val) {
336                 case LDKCreationError_DescriptionTooLong:
337                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
338                 case LDKCreationError_RouteTooLong:
339                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
340                 case LDKCreationError_TimestampOutOfBounds:
341                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
342                 case LDKCreationError_InvalidAmount:
343                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
344                 case LDKCreationError_MissingRouteHints:
345                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
346                 default: abort();
347         }
348 }
349
350 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
351         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
352         if (UNLIKELY((*env)->ExceptionCheck(env))) {
353                 (*env)->ExceptionDescribe(env);
354                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
355         }
356         switch (ord) {
357                 case 0: return LDKCurrency_Bitcoin;
358                 case 1: return LDKCurrency_BitcoinTestnet;
359                 case 2: return LDKCurrency_Regtest;
360                 case 3: return LDKCurrency_Simnet;
361                 case 4: return LDKCurrency_Signet;
362         }
363         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
364         abort(); // Unreachable, but will let the compiler know we don't return here
365 }
366 static jclass Currency_class = NULL;
367 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
368 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
369 static jfieldID Currency_LDKCurrency_Regtest = NULL;
370 static jfieldID Currency_LDKCurrency_Simnet = NULL;
371 static jfieldID Currency_LDKCurrency_Signet = NULL;
372 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
373         Currency_class = (*env)->NewGlobalRef(env, clz);
374         CHECK(Currency_class != NULL);
375         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
376         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
377         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
378         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
379         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
380         CHECK(Currency_LDKCurrency_Regtest != NULL);
381         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
382         CHECK(Currency_LDKCurrency_Simnet != NULL);
383         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
384         CHECK(Currency_LDKCurrency_Signet != NULL);
385 }
386 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
387         switch (val) {
388                 case LDKCurrency_Bitcoin:
389                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
390                 case LDKCurrency_BitcoinTestnet:
391                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
392                 case LDKCurrency_Regtest:
393                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
394                 case LDKCurrency_Simnet:
395                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
396                 case LDKCurrency_Signet:
397                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
398                 default: abort();
399         }
400 }
401
402 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
403         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
404         if (UNLIKELY((*env)->ExceptionCheck(env))) {
405                 (*env)->ExceptionDescribe(env);
406                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
407         }
408         switch (ord) {
409                 case 0: return LDKIOError_NotFound;
410                 case 1: return LDKIOError_PermissionDenied;
411                 case 2: return LDKIOError_ConnectionRefused;
412                 case 3: return LDKIOError_ConnectionReset;
413                 case 4: return LDKIOError_ConnectionAborted;
414                 case 5: return LDKIOError_NotConnected;
415                 case 6: return LDKIOError_AddrInUse;
416                 case 7: return LDKIOError_AddrNotAvailable;
417                 case 8: return LDKIOError_BrokenPipe;
418                 case 9: return LDKIOError_AlreadyExists;
419                 case 10: return LDKIOError_WouldBlock;
420                 case 11: return LDKIOError_InvalidInput;
421                 case 12: return LDKIOError_InvalidData;
422                 case 13: return LDKIOError_TimedOut;
423                 case 14: return LDKIOError_WriteZero;
424                 case 15: return LDKIOError_Interrupted;
425                 case 16: return LDKIOError_Other;
426                 case 17: return LDKIOError_UnexpectedEof;
427         }
428         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
429         abort(); // Unreachable, but will let the compiler know we don't return here
430 }
431 static jclass IOError_class = NULL;
432 static jfieldID IOError_LDKIOError_NotFound = NULL;
433 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
434 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
435 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
436 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
437 static jfieldID IOError_LDKIOError_NotConnected = NULL;
438 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
439 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
440 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
441 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
442 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
443 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
444 static jfieldID IOError_LDKIOError_InvalidData = NULL;
445 static jfieldID IOError_LDKIOError_TimedOut = NULL;
446 static jfieldID IOError_LDKIOError_WriteZero = NULL;
447 static jfieldID IOError_LDKIOError_Interrupted = NULL;
448 static jfieldID IOError_LDKIOError_Other = NULL;
449 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
450 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
451         IOError_class = (*env)->NewGlobalRef(env, clz);
452         CHECK(IOError_class != NULL);
453         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
454         CHECK(IOError_LDKIOError_NotFound != NULL);
455         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
456         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
457         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
458         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
459         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
460         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
461         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
462         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
463         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
464         CHECK(IOError_LDKIOError_NotConnected != NULL);
465         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
466         CHECK(IOError_LDKIOError_AddrInUse != NULL);
467         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
468         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
469         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
470         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
471         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
472         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
473         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
474         CHECK(IOError_LDKIOError_WouldBlock != NULL);
475         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
476         CHECK(IOError_LDKIOError_InvalidInput != NULL);
477         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
478         CHECK(IOError_LDKIOError_InvalidData != NULL);
479         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
480         CHECK(IOError_LDKIOError_TimedOut != NULL);
481         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
482         CHECK(IOError_LDKIOError_WriteZero != NULL);
483         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
484         CHECK(IOError_LDKIOError_Interrupted != NULL);
485         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
486         CHECK(IOError_LDKIOError_Other != NULL);
487         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
488         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
489 }
490 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
491         switch (val) {
492                 case LDKIOError_NotFound:
493                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
494                 case LDKIOError_PermissionDenied:
495                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
496                 case LDKIOError_ConnectionRefused:
497                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
498                 case LDKIOError_ConnectionReset:
499                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
500                 case LDKIOError_ConnectionAborted:
501                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
502                 case LDKIOError_NotConnected:
503                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
504                 case LDKIOError_AddrInUse:
505                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
506                 case LDKIOError_AddrNotAvailable:
507                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
508                 case LDKIOError_BrokenPipe:
509                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
510                 case LDKIOError_AlreadyExists:
511                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
512                 case LDKIOError_WouldBlock:
513                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
514                 case LDKIOError_InvalidInput:
515                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
516                 case LDKIOError_InvalidData:
517                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
518                 case LDKIOError_TimedOut:
519                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
520                 case LDKIOError_WriteZero:
521                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
522                 case LDKIOError_Interrupted:
523                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
524                 case LDKIOError_Other:
525                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
526                 case LDKIOError_UnexpectedEof:
527                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
528                 default: abort();
529         }
530 }
531
532 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
533         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
534         if (UNLIKELY((*env)->ExceptionCheck(env))) {
535                 (*env)->ExceptionDescribe(env);
536                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
537         }
538         switch (ord) {
539                 case 0: return LDKLevel_Gossip;
540                 case 1: return LDKLevel_Trace;
541                 case 2: return LDKLevel_Debug;
542                 case 3: return LDKLevel_Info;
543                 case 4: return LDKLevel_Warn;
544                 case 5: return LDKLevel_Error;
545         }
546         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
547         abort(); // Unreachable, but will let the compiler know we don't return here
548 }
549 static jclass Level_class = NULL;
550 static jfieldID Level_LDKLevel_Gossip = NULL;
551 static jfieldID Level_LDKLevel_Trace = NULL;
552 static jfieldID Level_LDKLevel_Debug = NULL;
553 static jfieldID Level_LDKLevel_Info = NULL;
554 static jfieldID Level_LDKLevel_Warn = NULL;
555 static jfieldID Level_LDKLevel_Error = NULL;
556 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
557         Level_class = (*env)->NewGlobalRef(env, clz);
558         CHECK(Level_class != NULL);
559         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
560         CHECK(Level_LDKLevel_Gossip != NULL);
561         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
562         CHECK(Level_LDKLevel_Trace != NULL);
563         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
564         CHECK(Level_LDKLevel_Debug != NULL);
565         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
566         CHECK(Level_LDKLevel_Info != NULL);
567         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
568         CHECK(Level_LDKLevel_Warn != NULL);
569         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
570         CHECK(Level_LDKLevel_Error != NULL);
571 }
572 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
573         switch (val) {
574                 case LDKLevel_Gossip:
575                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
576                 case LDKLevel_Trace:
577                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
578                 case LDKLevel_Debug:
579                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
580                 case LDKLevel_Info:
581                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
582                 case LDKLevel_Warn:
583                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
584                 case LDKLevel_Error:
585                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
586                 default: abort();
587         }
588 }
589
590 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
591         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
592         if (UNLIKELY((*env)->ExceptionCheck(env))) {
593                 (*env)->ExceptionDescribe(env);
594                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
595         }
596         switch (ord) {
597                 case 0: return LDKNetwork_Bitcoin;
598                 case 1: return LDKNetwork_Testnet;
599                 case 2: return LDKNetwork_Regtest;
600                 case 3: return LDKNetwork_Signet;
601         }
602         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
603         abort(); // Unreachable, but will let the compiler know we don't return here
604 }
605 static jclass Network_class = NULL;
606 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
607 static jfieldID Network_LDKNetwork_Testnet = NULL;
608 static jfieldID Network_LDKNetwork_Regtest = NULL;
609 static jfieldID Network_LDKNetwork_Signet = NULL;
610 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
611         Network_class = (*env)->NewGlobalRef(env, clz);
612         CHECK(Network_class != NULL);
613         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
614         CHECK(Network_LDKNetwork_Bitcoin != NULL);
615         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
616         CHECK(Network_LDKNetwork_Testnet != NULL);
617         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
618         CHECK(Network_LDKNetwork_Regtest != NULL);
619         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
620         CHECK(Network_LDKNetwork_Signet != NULL);
621 }
622 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
623         switch (val) {
624                 case LDKNetwork_Bitcoin:
625                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
626                 case LDKNetwork_Testnet:
627                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
628                 case LDKNetwork_Regtest:
629                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
630                 case LDKNetwork_Signet:
631                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
632                 default: abort();
633         }
634 }
635
636 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
637         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
638         if (UNLIKELY((*env)->ExceptionCheck(env))) {
639                 (*env)->ExceptionDescribe(env);
640                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
641         }
642         switch (ord) {
643                 case 0: return LDKRecipient_Node;
644                 case 1: return LDKRecipient_PhantomNode;
645         }
646         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
647         abort(); // Unreachable, but will let the compiler know we don't return here
648 }
649 static jclass Recipient_class = NULL;
650 static jfieldID Recipient_LDKRecipient_Node = NULL;
651 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
652 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
653         Recipient_class = (*env)->NewGlobalRef(env, clz);
654         CHECK(Recipient_class != NULL);
655         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
656         CHECK(Recipient_LDKRecipient_Node != NULL);
657         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
658         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
659 }
660 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
661         switch (val) {
662                 case LDKRecipient_Node:
663                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
664                 case LDKRecipient_PhantomNode:
665                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
666                 default: abort();
667         }
668 }
669
670 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
671         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
672         if (UNLIKELY((*env)->ExceptionCheck(env))) {
673                 (*env)->ExceptionDescribe(env);
674                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
675         }
676         switch (ord) {
677                 case 0: return LDKSecp256k1Error_IncorrectSignature;
678                 case 1: return LDKSecp256k1Error_InvalidMessage;
679                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
680                 case 3: return LDKSecp256k1Error_InvalidSignature;
681                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
682                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
683                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
684                 case 7: return LDKSecp256k1Error_InvalidTweak;
685                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
686                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
687                 case 10: return LDKSecp256k1Error_InvalidParityValue;
688         }
689         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
690         abort(); // Unreachable, but will let the compiler know we don't return here
691 }
692 static jclass Secp256k1Error_class = NULL;
693 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
694 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
695 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
696 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
697 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
698 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
699 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
700 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
701 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
702 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
703 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
704 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
705         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
706         CHECK(Secp256k1Error_class != NULL);
707         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
708         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
709         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
710         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
711         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
712         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
713         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
714         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
715         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
716         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
717         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
718         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
719         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
720         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
721         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
722         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
723         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
724         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
725         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
726         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
727         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
728         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
729 }
730 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
731         switch (val) {
732                 case LDKSecp256k1Error_IncorrectSignature:
733                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
734                 case LDKSecp256k1Error_InvalidMessage:
735                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
736                 case LDKSecp256k1Error_InvalidPublicKey:
737                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
738                 case LDKSecp256k1Error_InvalidSignature:
739                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
740                 case LDKSecp256k1Error_InvalidSecretKey:
741                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
742                 case LDKSecp256k1Error_InvalidSharedSecret:
743                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
744                 case LDKSecp256k1Error_InvalidRecoveryId:
745                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
746                 case LDKSecp256k1Error_InvalidTweak:
747                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
748                 case LDKSecp256k1Error_NotEnoughMemory:
749                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
750                 case LDKSecp256k1Error_InvalidPublicKeySum:
751                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
752                 case LDKSecp256k1Error_InvalidParityValue:
753                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
754                 default: abort();
755         }
756 }
757
758 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
759         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
760         if (UNLIKELY((*env)->ExceptionCheck(env))) {
761                 (*env)->ExceptionDescribe(env);
762                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
763         }
764         switch (ord) {
765                 case 0: return LDKSemanticError_NoPaymentHash;
766                 case 1: return LDKSemanticError_MultiplePaymentHashes;
767                 case 2: return LDKSemanticError_NoDescription;
768                 case 3: return LDKSemanticError_MultipleDescriptions;
769                 case 4: return LDKSemanticError_NoPaymentSecret;
770                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
771                 case 6: return LDKSemanticError_InvalidFeatures;
772                 case 7: return LDKSemanticError_InvalidRecoveryId;
773                 case 8: return LDKSemanticError_InvalidSignature;
774                 case 9: return LDKSemanticError_ImpreciseAmount;
775         }
776         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
777         abort(); // Unreachable, but will let the compiler know we don't return here
778 }
779 static jclass SemanticError_class = NULL;
780 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
781 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
782 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
783 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
784 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
785 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
786 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
787 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
788 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
789 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
790 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
791         SemanticError_class = (*env)->NewGlobalRef(env, clz);
792         CHECK(SemanticError_class != NULL);
793         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
794         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
795         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
796         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
797         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
798         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
799         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
800         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
801         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
802         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
803         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
804         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
805         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
806         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
807         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
808         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
809         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
810         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
811         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
812         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
813 }
814 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
815         switch (val) {
816                 case LDKSemanticError_NoPaymentHash:
817                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
818                 case LDKSemanticError_MultiplePaymentHashes:
819                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
820                 case LDKSemanticError_NoDescription:
821                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
822                 case LDKSemanticError_MultipleDescriptions:
823                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
824                 case LDKSemanticError_NoPaymentSecret:
825                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
826                 case LDKSemanticError_MultiplePaymentSecrets:
827                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
828                 case LDKSemanticError_InvalidFeatures:
829                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
830                 case LDKSemanticError_InvalidRecoveryId:
831                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
832                 case LDKSemanticError_InvalidSignature:
833                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
834                 case LDKSemanticError_ImpreciseAmount:
835                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
836                 default: abort();
837         }
838 }
839
840 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
841         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
842         if (UNLIKELY((*env)->ExceptionCheck(env))) {
843                 (*env)->ExceptionDescribe(env);
844                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
845         }
846         switch (ord) {
847                 case 0: return LDKSiPrefix_Milli;
848                 case 1: return LDKSiPrefix_Micro;
849                 case 2: return LDKSiPrefix_Nano;
850                 case 3: return LDKSiPrefix_Pico;
851         }
852         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
853         abort(); // Unreachable, but will let the compiler know we don't return here
854 }
855 static jclass SiPrefix_class = NULL;
856 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
857 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
858 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
859 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
860 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
861         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
862         CHECK(SiPrefix_class != NULL);
863         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
864         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
865         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
866         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
867         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
868         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
869         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
870         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
871 }
872 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
873         switch (val) {
874                 case LDKSiPrefix_Milli:
875                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
876                 case LDKSiPrefix_Micro:
877                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
878                 case LDKSiPrefix_Nano:
879                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
880                 case LDKSiPrefix_Pico:
881                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
882                 default: abort();
883         }
884 }
885
886 static jclass LDKBech32Error_MissingSeparator_class = NULL;
887 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
888 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
889 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
890 static jclass LDKBech32Error_InvalidLength_class = NULL;
891 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
892 static jclass LDKBech32Error_InvalidChar_class = NULL;
893 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
894 static jclass LDKBech32Error_InvalidData_class = NULL;
895 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
896 static jclass LDKBech32Error_InvalidPadding_class = NULL;
897 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
898 static jclass LDKBech32Error_MixedCase_class = NULL;
899 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
901         LDKBech32Error_MissingSeparator_class =
902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
903         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
904         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
905         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
906         LDKBech32Error_InvalidChecksum_class =
907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
908         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
909         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
910         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
911         LDKBech32Error_InvalidLength_class =
912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
913         CHECK(LDKBech32Error_InvalidLength_class != NULL);
914         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
915         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
916         LDKBech32Error_InvalidChar_class =
917                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
918         CHECK(LDKBech32Error_InvalidChar_class != NULL);
919         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
920         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
921         LDKBech32Error_InvalidData_class =
922                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
923         CHECK(LDKBech32Error_InvalidData_class != NULL);
924         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
925         CHECK(LDKBech32Error_InvalidData_meth != NULL);
926         LDKBech32Error_InvalidPadding_class =
927                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
928         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
929         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
930         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
931         LDKBech32Error_MixedCase_class =
932                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
933         CHECK(LDKBech32Error_MixedCase_class != NULL);
934         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
935         CHECK(LDKBech32Error_MixedCase_meth != NULL);
936 }
937 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
938         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
939         switch(obj->tag) {
940                 case LDKBech32Error_MissingSeparator: {
941                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
942                 }
943                 case LDKBech32Error_InvalidChecksum: {
944                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
945                 }
946                 case LDKBech32Error_InvalidLength: {
947                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
948                 }
949                 case LDKBech32Error_InvalidChar: {
950                         int32_t invalid_char_conv = obj->invalid_char;
951                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
952                 }
953                 case LDKBech32Error_InvalidData: {
954                         int8_t invalid_data_conv = obj->invalid_data;
955                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
956                 }
957                 case LDKBech32Error_InvalidPadding: {
958                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
959                 }
960                 case LDKBech32Error_MixedCase: {
961                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
962                 }
963                 default: abort();
964         }
965 }
966 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
967         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
968         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
969         return ret;
970 }
971 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t thing) {
972         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
973         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
974         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
975         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
976         CVec_u8Z_free(ret_var);
977         return ret_arr;
978 }
979
980 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1get_1value(JNIEnv *env, jclass clz, int64_t thing) {
981         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
982         int64_t ret_conv = TxOut_get_value(thing_conv);
983         return ret_conv;
984 }
985
986 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
987 CHECK(owner->result_ok);
988         return *owner->contents.result;
989 }
990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
991         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
992         CResult_NoneNoneZ_get_ok(owner_conv);
993 }
994
995 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
996 CHECK(!owner->result_ok);
997         return *owner->contents.err;
998 }
999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1000         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
1001         CResult_NoneNoneZ_get_err(owner_conv);
1002 }
1003
1004 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1005 CHECK(owner->result_ok);
1006         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
1007 }
1008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1009         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1010         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1011         int64_t ret_ref = 0;
1012         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1013         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1015         ret_ref = (uintptr_t)ret_var.inner;
1016         if (ret_var.is_owned) {
1017                 ret_ref |= 1;
1018         }
1019         return ret_ref;
1020 }
1021
1022 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1023 CHECK(!owner->result_ok);
1024         return DecodeError_clone(&*owner->contents.err);
1025 }
1026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1027         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1028         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1029         int64_t ret_ref = 0;
1030         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1031         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1033         ret_ref = (uintptr_t)ret_var.inner;
1034         if (ret_var.is_owned) {
1035                 ret_ref |= 1;
1036         }
1037         return ret_ref;
1038 }
1039
1040 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1041 CHECK(owner->result_ok);
1042         return *owner->contents.result;
1043 }
1044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1045         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1046         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1047         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1048         return ret_arr;
1049 }
1050
1051 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1052 CHECK(!owner->result_ok);
1053         return *owner->contents.err;
1054 }
1055 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1056         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1057         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1058         return ret_conv;
1059 }
1060
1061 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1062 CHECK(owner->result_ok);
1063         return *owner->contents.result;
1064 }
1065 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1066         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1067         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1068         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1069         return ret_arr;
1070 }
1071
1072 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1073 CHECK(!owner->result_ok);
1074         return *owner->contents.err;
1075 }
1076 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1077         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1078         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1079         return ret_conv;
1080 }
1081
1082 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1083 CHECK(owner->result_ok);
1084         return TxCreationKeys_clone(&*owner->contents.result);
1085 }
1086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1087         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1088         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1089         int64_t ret_ref = 0;
1090         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1091         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1093         ret_ref = (uintptr_t)ret_var.inner;
1094         if (ret_var.is_owned) {
1095                 ret_ref |= 1;
1096         }
1097         return ret_ref;
1098 }
1099
1100 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1101 CHECK(!owner->result_ok);
1102         return DecodeError_clone(&*owner->contents.err);
1103 }
1104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1105         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1106         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1107         int64_t ret_ref = 0;
1108         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1109         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1111         ret_ref = (uintptr_t)ret_var.inner;
1112         if (ret_var.is_owned) {
1113                 ret_ref |= 1;
1114         }
1115         return ret_ref;
1116 }
1117
1118 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1119 CHECK(owner->result_ok);
1120         return ChannelPublicKeys_clone(&*owner->contents.result);
1121 }
1122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1123         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1124         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1125         int64_t ret_ref = 0;
1126         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1127         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1129         ret_ref = (uintptr_t)ret_var.inner;
1130         if (ret_var.is_owned) {
1131                 ret_ref |= 1;
1132         }
1133         return ret_ref;
1134 }
1135
1136 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1137 CHECK(!owner->result_ok);
1138         return DecodeError_clone(&*owner->contents.err);
1139 }
1140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1141         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1142         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1143         int64_t ret_ref = 0;
1144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1147         ret_ref = (uintptr_t)ret_var.inner;
1148         if (ret_var.is_owned) {
1149                 ret_ref |= 1;
1150         }
1151         return ret_ref;
1152 }
1153
1154 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1155 CHECK(owner->result_ok);
1156         return TxCreationKeys_clone(&*owner->contents.result);
1157 }
1158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1159         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1160         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1161         int64_t ret_ref = 0;
1162         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1163         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1165         ret_ref = (uintptr_t)ret_var.inner;
1166         if (ret_var.is_owned) {
1167                 ret_ref |= 1;
1168         }
1169         return ret_ref;
1170 }
1171
1172 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1173 CHECK(!owner->result_ok);
1174         return *owner->contents.err;
1175 }
1176 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1177         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1178         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1179         return ret_conv;
1180 }
1181
1182 static jclass LDKCOption_u32Z_Some_class = NULL;
1183 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1184 static jclass LDKCOption_u32Z_None_class = NULL;
1185 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1187         LDKCOption_u32Z_Some_class =
1188                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1189         CHECK(LDKCOption_u32Z_Some_class != NULL);
1190         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1191         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1192         LDKCOption_u32Z_None_class =
1193                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1194         CHECK(LDKCOption_u32Z_None_class != NULL);
1195         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1196         CHECK(LDKCOption_u32Z_None_meth != NULL);
1197 }
1198 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1199         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
1200         switch(obj->tag) {
1201                 case LDKCOption_u32Z_Some: {
1202                         int32_t some_conv = obj->some;
1203                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1204                 }
1205                 case LDKCOption_u32Z_None: {
1206                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1207                 }
1208                 default: abort();
1209         }
1210 }
1211 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1212 CHECK(owner->result_ok);
1213         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1214 }
1215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1216         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1217         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1218         int64_t ret_ref = 0;
1219         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1220         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1222         ret_ref = (uintptr_t)ret_var.inner;
1223         if (ret_var.is_owned) {
1224                 ret_ref |= 1;
1225         }
1226         return ret_ref;
1227 }
1228
1229 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1230 CHECK(!owner->result_ok);
1231         return DecodeError_clone(&*owner->contents.err);
1232 }
1233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1234         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1235         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1236         int64_t ret_ref = 0;
1237         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1238         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1240         ret_ref = (uintptr_t)ret_var.inner;
1241         if (ret_var.is_owned) {
1242                 ret_ref |= 1;
1243         }
1244         return ret_ref;
1245 }
1246
1247 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1248 CHECK(owner->result_ok);
1249         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1250 }
1251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1252         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1253         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1254         int64_t ret_ref = 0;
1255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1258         ret_ref = (uintptr_t)ret_var.inner;
1259         if (ret_var.is_owned) {
1260                 ret_ref |= 1;
1261         }
1262         return ret_ref;
1263 }
1264
1265 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1266 CHECK(!owner->result_ok);
1267         return DecodeError_clone(&*owner->contents.err);
1268 }
1269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1270         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1271         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1272         int64_t ret_ref = 0;
1273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1276         ret_ref = (uintptr_t)ret_var.inner;
1277         if (ret_var.is_owned) {
1278                 ret_ref |= 1;
1279         }
1280         return ret_ref;
1281 }
1282
1283 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1284 CHECK(owner->result_ok);
1285         return ChannelTransactionParameters_clone(&*owner->contents.result);
1286 }
1287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1288         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1289         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1290         int64_t ret_ref = 0;
1291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1294         ret_ref = (uintptr_t)ret_var.inner;
1295         if (ret_var.is_owned) {
1296                 ret_ref |= 1;
1297         }
1298         return ret_ref;
1299 }
1300
1301 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1302 CHECK(!owner->result_ok);
1303         return DecodeError_clone(&*owner->contents.err);
1304 }
1305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1306         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1307         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1308         int64_t ret_ref = 0;
1309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1312         ret_ref = (uintptr_t)ret_var.inner;
1313         if (ret_var.is_owned) {
1314                 ret_ref |= 1;
1315         }
1316         return ret_ref;
1317 }
1318
1319 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1320 CHECK(owner->result_ok);
1321         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1322 }
1323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1324         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1325         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1326         int64_t ret_ref = 0;
1327         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1328         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1330         ret_ref = (uintptr_t)ret_var.inner;
1331         if (ret_var.is_owned) {
1332                 ret_ref |= 1;
1333         }
1334         return ret_ref;
1335 }
1336
1337 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1338 CHECK(!owner->result_ok);
1339         return DecodeError_clone(&*owner->contents.err);
1340 }
1341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1342         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1343         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1344         int64_t ret_ref = 0;
1345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1348         ret_ref = (uintptr_t)ret_var.inner;
1349         if (ret_var.is_owned) {
1350                 ret_ref |= 1;
1351         }
1352         return ret_ref;
1353 }
1354
1355 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1356 CHECK(owner->result_ok);
1357         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1358 }
1359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1360         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1361         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1362         int64_t ret_ref = 0;
1363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1366         ret_ref = (uintptr_t)ret_var.inner;
1367         if (ret_var.is_owned) {
1368                 ret_ref |= 1;
1369         }
1370         return ret_ref;
1371 }
1372
1373 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1374 CHECK(!owner->result_ok);
1375         return DecodeError_clone(&*owner->contents.err);
1376 }
1377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1378         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1379         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1380         int64_t ret_ref = 0;
1381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1384         ret_ref = (uintptr_t)ret_var.inner;
1385         if (ret_var.is_owned) {
1386                 ret_ref |= 1;
1387         }
1388         return ret_ref;
1389 }
1390
1391 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1392 CHECK(owner->result_ok);
1393         return &*owner->contents.result;
1394 }
1395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1396         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1397         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1398         int64_t ret_ref = 0;
1399         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1400         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1402         ret_ref = (uintptr_t)ret_var.inner & ~1;
1403         return ret_ref;
1404 }
1405
1406 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1407 CHECK(!owner->result_ok);
1408         return *owner->contents.err;
1409 }
1410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1411         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1412         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1413 }
1414
1415 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1416 CHECK(owner->result_ok);
1417         return CommitmentTransaction_clone(&*owner->contents.result);
1418 }
1419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1420         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1421         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1422         int64_t ret_ref = 0;
1423         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1424         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1426         ret_ref = (uintptr_t)ret_var.inner;
1427         if (ret_var.is_owned) {
1428                 ret_ref |= 1;
1429         }
1430         return ret_ref;
1431 }
1432
1433 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1434 CHECK(!owner->result_ok);
1435         return DecodeError_clone(&*owner->contents.err);
1436 }
1437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1438         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1439         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1440         int64_t ret_ref = 0;
1441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1444         ret_ref = (uintptr_t)ret_var.inner;
1445         if (ret_var.is_owned) {
1446                 ret_ref |= 1;
1447         }
1448         return ret_ref;
1449 }
1450
1451 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1452 CHECK(owner->result_ok);
1453         return &*owner->contents.result;
1454 }
1455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1456         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1457         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1458         int64_t ret_ref = 0;
1459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1462         ret_ref = (uintptr_t)ret_var.inner & ~1;
1463         return ret_ref;
1464 }
1465
1466 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1467 CHECK(!owner->result_ok);
1468         return *owner->contents.err;
1469 }
1470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1471         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1472         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1473 }
1474
1475 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1476 CHECK(owner->result_ok);
1477         return *owner->contents.result;
1478 }
1479 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1480         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1481         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1482         jobjectArray ret_arr = NULL;
1483         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1484         ;
1485         for (size_t i = 0; i < ret_var.datalen; i++) {
1486                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1487                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1488                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1489         }
1490         
1491         return ret_arr;
1492 }
1493
1494 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1495 CHECK(!owner->result_ok);
1496         return *owner->contents.err;
1497 }
1498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1499         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1500         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1501 }
1502
1503 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1504 CHECK(owner->result_ok);
1505         return ShutdownScript_clone(&*owner->contents.result);
1506 }
1507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1508         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1509         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1510         int64_t ret_ref = 0;
1511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1514         ret_ref = (uintptr_t)ret_var.inner;
1515         if (ret_var.is_owned) {
1516                 ret_ref |= 1;
1517         }
1518         return ret_ref;
1519 }
1520
1521 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1522 CHECK(!owner->result_ok);
1523         return DecodeError_clone(&*owner->contents.err);
1524 }
1525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1526         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1527         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1528         int64_t ret_ref = 0;
1529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1532         ret_ref = (uintptr_t)ret_var.inner;
1533         if (ret_var.is_owned) {
1534                 ret_ref |= 1;
1535         }
1536         return ret_ref;
1537 }
1538
1539 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1540 CHECK(owner->result_ok);
1541         return ShutdownScript_clone(&*owner->contents.result);
1542 }
1543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1544         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1545         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1546         int64_t ret_ref = 0;
1547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1550         ret_ref = (uintptr_t)ret_var.inner;
1551         if (ret_var.is_owned) {
1552                 ret_ref |= 1;
1553         }
1554         return ret_ref;
1555 }
1556
1557 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1558 CHECK(!owner->result_ok);
1559         return InvalidShutdownScript_clone(&*owner->contents.err);
1560 }
1561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1562         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1563         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1564         int64_t ret_ref = 0;
1565         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1566         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1568         ret_ref = (uintptr_t)ret_var.inner;
1569         if (ret_var.is_owned) {
1570                 ret_ref |= 1;
1571         }
1572         return ret_ref;
1573 }
1574
1575 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1576 CHECK(owner->result_ok);
1577         return *owner->contents.result;
1578 }
1579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1580         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1581         CResult_NoneErrorZ_get_ok(owner_conv);
1582 }
1583
1584 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1585 CHECK(!owner->result_ok);
1586         return *owner->contents.err;
1587 }
1588 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1589         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1590         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1591         return ret_conv;
1592 }
1593
1594 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1595 CHECK(owner->result_ok);
1596         return RouteHop_clone(&*owner->contents.result);
1597 }
1598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1599         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1600         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1601         int64_t ret_ref = 0;
1602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1605         ret_ref = (uintptr_t)ret_var.inner;
1606         if (ret_var.is_owned) {
1607                 ret_ref |= 1;
1608         }
1609         return ret_ref;
1610 }
1611
1612 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1613 CHECK(!owner->result_ok);
1614         return DecodeError_clone(&*owner->contents.err);
1615 }
1616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1617         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1618         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1619         int64_t ret_ref = 0;
1620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1623         ret_ref = (uintptr_t)ret_var.inner;
1624         if (ret_var.is_owned) {
1625                 ret_ref |= 1;
1626         }
1627         return ret_ref;
1628 }
1629
1630 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1631         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1632         for (size_t i = 0; i < ret.datalen; i++) {
1633                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1634         }
1635         return ret;
1636 }
1637 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1638         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1639         for (size_t i = 0; i < ret.datalen; i++) {
1640                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1641         }
1642         return ret;
1643 }
1644 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1645 CHECK(owner->result_ok);
1646         return Route_clone(&*owner->contents.result);
1647 }
1648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1649         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1650         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1651         int64_t ret_ref = 0;
1652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1655         ret_ref = (uintptr_t)ret_var.inner;
1656         if (ret_var.is_owned) {
1657                 ret_ref |= 1;
1658         }
1659         return ret_ref;
1660 }
1661
1662 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1663 CHECK(!owner->result_ok);
1664         return DecodeError_clone(&*owner->contents.err);
1665 }
1666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1667         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1668         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1669         int64_t ret_ref = 0;
1670         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1671         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1673         ret_ref = (uintptr_t)ret_var.inner;
1674         if (ret_var.is_owned) {
1675                 ret_ref |= 1;
1676         }
1677         return ret_ref;
1678 }
1679
1680 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1681 CHECK(owner->result_ok);
1682         return RouteParameters_clone(&*owner->contents.result);
1683 }
1684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1685         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1686         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1687         int64_t ret_ref = 0;
1688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1691         ret_ref = (uintptr_t)ret_var.inner;
1692         if (ret_var.is_owned) {
1693                 ret_ref |= 1;
1694         }
1695         return ret_ref;
1696 }
1697
1698 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1699 CHECK(!owner->result_ok);
1700         return DecodeError_clone(&*owner->contents.err);
1701 }
1702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1703         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1704         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1705         int64_t ret_ref = 0;
1706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1709         ret_ref = (uintptr_t)ret_var.inner;
1710         if (ret_var.is_owned) {
1711                 ret_ref |= 1;
1712         }
1713         return ret_ref;
1714 }
1715
1716 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1717         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1718         for (size_t i = 0; i < ret.datalen; i++) {
1719                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1720         }
1721         return ret;
1722 }
1723 static jclass LDKCOption_u64Z_Some_class = NULL;
1724 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1725 static jclass LDKCOption_u64Z_None_class = NULL;
1726 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1728         LDKCOption_u64Z_Some_class =
1729                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1730         CHECK(LDKCOption_u64Z_Some_class != NULL);
1731         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1732         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1733         LDKCOption_u64Z_None_class =
1734                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1735         CHECK(LDKCOption_u64Z_None_class != NULL);
1736         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1737         CHECK(LDKCOption_u64Z_None_meth != NULL);
1738 }
1739 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1740         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1741         switch(obj->tag) {
1742                 case LDKCOption_u64Z_Some: {
1743                         int64_t some_conv = obj->some;
1744                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
1745                 }
1746                 case LDKCOption_u64Z_None: {
1747                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1748                 }
1749                 default: abort();
1750         }
1751 }
1752 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1753 CHECK(owner->result_ok);
1754         return PaymentParameters_clone(&*owner->contents.result);
1755 }
1756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1757         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1758         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1759         int64_t ret_ref = 0;
1760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1763         ret_ref = (uintptr_t)ret_var.inner;
1764         if (ret_var.is_owned) {
1765                 ret_ref |= 1;
1766         }
1767         return ret_ref;
1768 }
1769
1770 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1771 CHECK(!owner->result_ok);
1772         return DecodeError_clone(&*owner->contents.err);
1773 }
1774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1775         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1776         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1777         int64_t ret_ref = 0;
1778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1781         ret_ref = (uintptr_t)ret_var.inner;
1782         if (ret_var.is_owned) {
1783                 ret_ref |= 1;
1784         }
1785         return ret_ref;
1786 }
1787
1788 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1789         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1790         for (size_t i = 0; i < ret.datalen; i++) {
1791                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1792         }
1793         return ret;
1794 }
1795 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1796 CHECK(owner->result_ok);
1797         return RouteHint_clone(&*owner->contents.result);
1798 }
1799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1800         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1801         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1802         int64_t ret_ref = 0;
1803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1806         ret_ref = (uintptr_t)ret_var.inner;
1807         if (ret_var.is_owned) {
1808                 ret_ref |= 1;
1809         }
1810         return ret_ref;
1811 }
1812
1813 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1814 CHECK(!owner->result_ok);
1815         return DecodeError_clone(&*owner->contents.err);
1816 }
1817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1818         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1819         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1820         int64_t ret_ref = 0;
1821         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1822         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1824         ret_ref = (uintptr_t)ret_var.inner;
1825         if (ret_var.is_owned) {
1826                 ret_ref |= 1;
1827         }
1828         return ret_ref;
1829 }
1830
1831 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1832 CHECK(owner->result_ok);
1833         return RouteHintHop_clone(&*owner->contents.result);
1834 }
1835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1836         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1837         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1838         int64_t ret_ref = 0;
1839         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1840         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1842         ret_ref = (uintptr_t)ret_var.inner;
1843         if (ret_var.is_owned) {
1844                 ret_ref |= 1;
1845         }
1846         return ret_ref;
1847 }
1848
1849 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1850 CHECK(!owner->result_ok);
1851         return DecodeError_clone(&*owner->contents.err);
1852 }
1853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1854         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1855         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1856         int64_t ret_ref = 0;
1857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1860         ret_ref = (uintptr_t)ret_var.inner;
1861         if (ret_var.is_owned) {
1862                 ret_ref |= 1;
1863         }
1864         return ret_ref;
1865 }
1866
1867 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1868         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1869         for (size_t i = 0; i < ret.datalen; i++) {
1870                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1871         }
1872         return ret;
1873 }
1874 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1875 CHECK(owner->result_ok);
1876         return Route_clone(&*owner->contents.result);
1877 }
1878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1879         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1880         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1881         int64_t ret_ref = 0;
1882         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1883         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1885         ret_ref = (uintptr_t)ret_var.inner;
1886         if (ret_var.is_owned) {
1887                 ret_ref |= 1;
1888         }
1889         return ret_ref;
1890 }
1891
1892 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1893 CHECK(!owner->result_ok);
1894         return LightningError_clone(&*owner->contents.err);
1895 }
1896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1897         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1898         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1899         int64_t ret_ref = 0;
1900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1903         ret_ref = (uintptr_t)ret_var.inner;
1904         if (ret_var.is_owned) {
1905                 ret_ref |= 1;
1906         }
1907         return ret_ref;
1908 }
1909
1910 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
1911 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
1912 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
1913 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
1914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
1915         LDKPaymentPurpose_InvoicePayment_class =
1916                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
1917         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
1918         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
1919         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
1920         LDKPaymentPurpose_SpontaneousPayment_class =
1921                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
1922         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
1923         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
1924         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
1925 }
1926 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1927         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1928         switch(obj->tag) {
1929                 case LDKPaymentPurpose_InvoicePayment: {
1930                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1931                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
1932                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1933                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
1934                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
1935                 }
1936                 case LDKPaymentPurpose_SpontaneousPayment: {
1937                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
1938                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
1939                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
1940                 }
1941                 default: abort();
1942         }
1943 }
1944 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1945 CHECK(owner->result_ok);
1946         return PaymentPurpose_clone(&*owner->contents.result);
1947 }
1948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1949         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1950         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1951         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1952         int64_t ret_ref = (uintptr_t)ret_copy;
1953         return ret_ref;
1954 }
1955
1956 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1957 CHECK(!owner->result_ok);
1958         return DecodeError_clone(&*owner->contents.err);
1959 }
1960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1961         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1962         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1963         int64_t ret_ref = 0;
1964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1967         ret_ref = (uintptr_t)ret_var.inner;
1968         if (ret_var.is_owned) {
1969                 ret_ref |= 1;
1970         }
1971         return ret_ref;
1972 }
1973
1974 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
1975 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
1976 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
1977 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
1978 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
1979 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
1980 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
1981 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
1982 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
1983 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
1984 static jclass LDKClosureReason_ProcessingError_class = NULL;
1985 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
1986 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
1987 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
1988 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
1989 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
1990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
1991         LDKClosureReason_CounterpartyForceClosed_class =
1992                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
1993         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
1994         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
1995         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
1996         LDKClosureReason_HolderForceClosed_class =
1997                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
1998         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
1999         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2000         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2001         LDKClosureReason_CooperativeClosure_class =
2002                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2003         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2004         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2005         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2006         LDKClosureReason_CommitmentTxConfirmed_class =
2007                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2008         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2009         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2010         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2011         LDKClosureReason_FundingTimedOut_class =
2012                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2013         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2014         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2015         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2016         LDKClosureReason_ProcessingError_class =
2017                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2018         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2019         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2020         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2021         LDKClosureReason_DisconnectedPeer_class =
2022                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2023         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2024         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2025         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2026         LDKClosureReason_OutdatedChannelManager_class =
2027                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2028         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2029         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2030         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2031 }
2032 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2033         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
2034         switch(obj->tag) {
2035                 case LDKClosureReason_CounterpartyForceClosed: {
2036                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2037                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2038                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2039                 }
2040                 case LDKClosureReason_HolderForceClosed: {
2041                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2042                 }
2043                 case LDKClosureReason_CooperativeClosure: {
2044                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2045                 }
2046                 case LDKClosureReason_CommitmentTxConfirmed: {
2047                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2048                 }
2049                 case LDKClosureReason_FundingTimedOut: {
2050                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2051                 }
2052                 case LDKClosureReason_ProcessingError: {
2053                         LDKStr err_str = obj->processing_error.err;
2054                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2055                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2056                 }
2057                 case LDKClosureReason_DisconnectedPeer: {
2058                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2059                 }
2060                 case LDKClosureReason_OutdatedChannelManager: {
2061                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2062                 }
2063                 default: abort();
2064         }
2065 }
2066 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2067 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2068 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2069 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2071         LDKCOption_ClosureReasonZ_Some_class =
2072                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2073         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2074         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2075         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2076         LDKCOption_ClosureReasonZ_None_class =
2077                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2078         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2079         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2080         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2081 }
2082 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2083         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2084         switch(obj->tag) {
2085                 case LDKCOption_ClosureReasonZ_Some: {
2086                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2087                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2088                 }
2089                 case LDKCOption_ClosureReasonZ_None: {
2090                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2091                 }
2092                 default: abort();
2093         }
2094 }
2095 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2096 CHECK(owner->result_ok);
2097         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2098 }
2099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2100         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2101         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2102         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2103         int64_t ret_ref = (uintptr_t)ret_copy;
2104         return ret_ref;
2105 }
2106
2107 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2108 CHECK(!owner->result_ok);
2109         return DecodeError_clone(&*owner->contents.err);
2110 }
2111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2112         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2113         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2114         int64_t ret_ref = 0;
2115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2118         ret_ref = (uintptr_t)ret_var.inner;
2119         if (ret_var.is_owned) {
2120                 ret_ref |= 1;
2121         }
2122         return ret_ref;
2123 }
2124
2125 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2126 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2127 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2128 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2129 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2130 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2132         LDKNetworkUpdate_ChannelUpdateMessage_class =
2133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2134         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2135         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2136         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2137         LDKNetworkUpdate_ChannelFailure_class =
2138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2139         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2140         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2141         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2142         LDKNetworkUpdate_NodeFailure_class =
2143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2144         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2145         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2146         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2147 }
2148 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2149         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2150         switch(obj->tag) {
2151                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2152                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2153                         int64_t msg_ref = 0;
2154                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2155                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2156                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2157                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2158                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2159                 }
2160                 case LDKNetworkUpdate_ChannelFailure: {
2161                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2162                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2163                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2164                 }
2165                 case LDKNetworkUpdate_NodeFailure: {
2166                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2167                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2168                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2169                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2170                 }
2171                 default: abort();
2172         }
2173 }
2174 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2175 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2176 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2177 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2179         LDKCOption_NetworkUpdateZ_Some_class =
2180                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2181         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2182         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2183         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2184         LDKCOption_NetworkUpdateZ_None_class =
2185                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2186         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2187         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2188         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2189 }
2190 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2191         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2192         switch(obj->tag) {
2193                 case LDKCOption_NetworkUpdateZ_Some: {
2194                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2195                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2196                 }
2197                 case LDKCOption_NetworkUpdateZ_None: {
2198                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2199                 }
2200                 default: abort();
2201         }
2202 }
2203 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2204 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2205 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2206 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2207 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2208 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2210         LDKSpendableOutputDescriptor_StaticOutput_class =
2211                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2212         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2213         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2214         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2215         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2216                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2217         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2218         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2219         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2220         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2221                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2222         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2223         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2224         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2225 }
2226 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2227         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2228         switch(obj->tag) {
2229                 case LDKSpendableOutputDescriptor_StaticOutput: {
2230                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2231                         int64_t outpoint_ref = 0;
2232                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2233                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2234                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2235                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2236                         int64_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2237                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (int64_t)output_ref);
2238                 }
2239                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2240                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2241                         int64_t delayed_payment_output_ref = 0;
2242                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2243                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2244                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2245                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2246                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2247                 }
2248                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2249                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2250                         int64_t static_payment_output_ref = 0;
2251                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2252                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2253                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2254                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2255                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2256                 }
2257                 default: abort();
2258         }
2259 }
2260 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2261         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2262         for (size_t i = 0; i < ret.datalen; i++) {
2263                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2264         }
2265         return ret;
2266 }
2267 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2268 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2269 static jclass LDKEvent_PaymentReceived_class = NULL;
2270 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2271 static jclass LDKEvent_PaymentClaimed_class = NULL;
2272 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
2273 static jclass LDKEvent_PaymentSent_class = NULL;
2274 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2275 static jclass LDKEvent_PaymentFailed_class = NULL;
2276 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2277 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2278 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2279 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2280 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2281 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2282 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2283 static jclass LDKEvent_SpendableOutputs_class = NULL;
2284 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2285 static jclass LDKEvent_PaymentForwarded_class = NULL;
2286 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2287 static jclass LDKEvent_ChannelClosed_class = NULL;
2288 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2289 static jclass LDKEvent_DiscardFunding_class = NULL;
2290 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2291 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2292 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2294         LDKEvent_FundingGenerationReady_class =
2295                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2296         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2297         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[BJ)V");
2298         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2299         LDKEvent_PaymentReceived_class =
2300                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2301         CHECK(LDKEvent_PaymentReceived_class != NULL);
2302         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2303         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2304         LDKEvent_PaymentClaimed_class =
2305                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
2306         CHECK(LDKEvent_PaymentClaimed_class != NULL);
2307         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([BJJ)V");
2308         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
2309         LDKEvent_PaymentSent_class =
2310                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2311         CHECK(LDKEvent_PaymentSent_class != NULL);
2312         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2313         CHECK(LDKEvent_PaymentSent_meth != NULL);
2314         LDKEvent_PaymentFailed_class =
2315                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2316         CHECK(LDKEvent_PaymentFailed_class != NULL);
2317         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2318         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2319         LDKEvent_PaymentPathSuccessful_class =
2320                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2321         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2322         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2323         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2324         LDKEvent_PaymentPathFailed_class =
2325                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2326         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2327         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2328         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2329         LDKEvent_PendingHTLCsForwardable_class =
2330                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2331         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2332         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2333         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2334         LDKEvent_SpendableOutputs_class =
2335                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2336         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2337         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2338         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2339         LDKEvent_PaymentForwarded_class =
2340                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2341         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2342         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
2343         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2344         LDKEvent_ChannelClosed_class =
2345                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2346         CHECK(LDKEvent_ChannelClosed_class != NULL);
2347         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2348         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2349         LDKEvent_DiscardFunding_class =
2350                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2351         CHECK(LDKEvent_DiscardFunding_class != NULL);
2352         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2353         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2354         LDKEvent_OpenChannelRequest_class =
2355                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2356         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2357         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
2358         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2359 }
2360 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2361         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2362         switch(obj->tag) {
2363                 case LDKEvent_FundingGenerationReady: {
2364                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2365                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2366                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2367                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
2368                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
2369                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2370                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2371                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2372                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
2373                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, counterparty_node_id_arr, channel_value_satoshis_conv, output_script_arr, user_channel_id_conv);
2374                 }
2375                 case LDKEvent_PaymentReceived: {
2376                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2377                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2378                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
2379                         int64_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2380                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2381                 }
2382                 case LDKEvent_PaymentClaimed: {
2383                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2384                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
2385                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
2386                         int64_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
2387                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
2388                 }
2389                 case LDKEvent_PaymentSent: {
2390                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2391                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2392                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2393                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2394                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2395                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2396                         int64_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2397                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2398                 }
2399                 case LDKEvent_PaymentFailed: {
2400                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2401                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2402                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2403                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2404                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2405                 }
2406                 case LDKEvent_PaymentPathSuccessful: {
2407                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2408                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2409                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2410                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2411                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2412                         int64_tArray path_arr = NULL;
2413                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2414                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2415                         for (size_t k = 0; k < path_var.datalen; k++) {
2416                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2417                                 int64_t path_conv_10_ref = 0;
2418                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2419                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2420                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2421                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2422                                 path_arr_ptr[k] = path_conv_10_ref;
2423                         }
2424                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2425                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2426                 }
2427                 case LDKEvent_PaymentPathFailed: {
2428                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2429                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2430                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2431                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2432                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
2433                         int64_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2434                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
2435                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2436                         int64_tArray path_arr = NULL;
2437                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2438                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2439                         for (size_t k = 0; k < path_var.datalen; k++) {
2440                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2441                                 int64_t path_conv_10_ref = 0;
2442                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2443                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2444                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2445                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2446                                 path_arr_ptr[k] = path_conv_10_ref;
2447                         }
2448                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2449                         int64_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2450                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2451                         int64_t retry_ref = 0;
2452                         if ((uintptr_t)retry_var.inner > 4096) {
2453                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2454                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2455                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2456                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2457                         }
2458                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, rejected_by_dest_conv, network_update_ref, all_paths_failed_conv, path_arr, short_channel_id_ref, retry_ref);
2459                 }
2460                 case LDKEvent_PendingHTLCsForwardable: {
2461                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
2462                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
2463                 }
2464                 case LDKEvent_SpendableOutputs: {
2465                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2466                         int64_tArray outputs_arr = NULL;
2467                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2468                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2469                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2470                                 int64_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2471                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2472                         }
2473                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2474                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2475                 }
2476                 case LDKEvent_PaymentForwarded: {
2477                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
2478                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
2479                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
2480                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
2481                         int64_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2482                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
2483                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, prev_channel_id_arr, next_channel_id_arr, fee_earned_msat_ref, claim_from_onchain_tx_conv);
2484                 }
2485                 case LDKEvent_ChannelClosed: {
2486                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2487                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2488                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
2489                         int64_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2490                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
2491                 }
2492                 case LDKEvent_DiscardFunding: {
2493                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2494                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2495                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2496                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2497                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2498                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2499                 }
2500                 case LDKEvent_OpenChannelRequest: {
2501                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2502                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2503                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2504                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2505                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2506                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2507                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2508                         int64_t channel_type_ref = 0;
2509                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2510                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2511                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2512                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2513                         return (*env)->NewObject(env, LDKEvent_OpenChannelRequest_class, LDKEvent_OpenChannelRequest_meth, temporary_channel_id_arr, counterparty_node_id_arr, funding_satoshis_conv, push_msat_conv, channel_type_ref);
2514                 }
2515                 default: abort();
2516         }
2517 }
2518 static jclass LDKCOption_EventZ_Some_class = NULL;
2519 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2520 static jclass LDKCOption_EventZ_None_class = NULL;
2521 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2523         LDKCOption_EventZ_Some_class =
2524                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2525         CHECK(LDKCOption_EventZ_Some_class != NULL);
2526         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2527         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2528         LDKCOption_EventZ_None_class =
2529                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2530         CHECK(LDKCOption_EventZ_None_class != NULL);
2531         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2532         CHECK(LDKCOption_EventZ_None_meth != NULL);
2533 }
2534 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2535         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2536         switch(obj->tag) {
2537                 case LDKCOption_EventZ_Some: {
2538                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2539                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2540                 }
2541                 case LDKCOption_EventZ_None: {
2542                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2543                 }
2544                 default: abort();
2545         }
2546 }
2547 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2548 CHECK(owner->result_ok);
2549         return COption_EventZ_clone(&*owner->contents.result);
2550 }
2551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2552         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2553         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2554         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2555         int64_t ret_ref = (uintptr_t)ret_copy;
2556         return ret_ref;
2557 }
2558
2559 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2560 CHECK(!owner->result_ok);
2561         return DecodeError_clone(&*owner->contents.err);
2562 }
2563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2564         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2565         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2566         int64_t ret_ref = 0;
2567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2570         ret_ref = (uintptr_t)ret_var.inner;
2571         if (ret_var.is_owned) {
2572                 ret_ref |= 1;
2573         }
2574         return ret_ref;
2575 }
2576
2577 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2578 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2579 static jclass LDKErrorAction_IgnoreError_class = NULL;
2580 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2581 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2582 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2583 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2584 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2585 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2586 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2587 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2588 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2590         LDKErrorAction_DisconnectPeer_class =
2591                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2592         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2593         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2594         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2595         LDKErrorAction_IgnoreError_class =
2596                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2597         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2598         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2599         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2600         LDKErrorAction_IgnoreAndLog_class =
2601                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2602         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2603         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2604         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2605         LDKErrorAction_IgnoreDuplicateGossip_class =
2606                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2607         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2608         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2609         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2610         LDKErrorAction_SendErrorMessage_class =
2611                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2612         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2613         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2614         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2615         LDKErrorAction_SendWarningMessage_class =
2616                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2617         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2618         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2619         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2620 }
2621 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2622         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2623         switch(obj->tag) {
2624                 case LDKErrorAction_DisconnectPeer: {
2625                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2626                         int64_t msg_ref = 0;
2627                         if ((uintptr_t)msg_var.inner > 4096) {
2628                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2629                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2630                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2631                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2632                         }
2633                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2634                 }
2635                 case LDKErrorAction_IgnoreError: {
2636                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2637                 }
2638                 case LDKErrorAction_IgnoreAndLog: {
2639                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2640                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2641                 }
2642                 case LDKErrorAction_IgnoreDuplicateGossip: {
2643                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2644                 }
2645                 case LDKErrorAction_SendErrorMessage: {
2646                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2647                         int64_t msg_ref = 0;
2648                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2649                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2650                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2651                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2652                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2653                 }
2654                 case LDKErrorAction_SendWarningMessage: {
2655                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2656                         int64_t msg_ref = 0;
2657                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2658                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2659                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2660                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2661                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2662                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2663                 }
2664                 default: abort();
2665         }
2666 }
2667 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2668 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2669 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2670 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2671 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2672 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2673 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2674 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2675 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
2676 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
2677 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2678 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2679 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2680 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2681 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2682 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2683 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2684 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2685 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2686 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2687 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2688 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2689 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2690 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2691 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2692 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2693 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2694 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2695 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2696 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2697 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2698 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2699 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2700 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2701 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2702 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2703 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2704 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2705 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
2706 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
2707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2708         LDKMessageSendEvent_SendAcceptChannel_class =
2709                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2710         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2711         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2712         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2713         LDKMessageSendEvent_SendOpenChannel_class =
2714                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2715         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2716         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2717         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2718         LDKMessageSendEvent_SendFundingCreated_class =
2719                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2720         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2721         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2722         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2723         LDKMessageSendEvent_SendFundingSigned_class =
2724                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2725         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2726         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2727         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2728         LDKMessageSendEvent_SendChannelReady_class =
2729                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
2730         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
2731         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
2732         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
2733         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2734                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2735         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2736         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2737         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2738         LDKMessageSendEvent_UpdateHTLCs_class =
2739                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2740         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2741         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2742         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2743         LDKMessageSendEvent_SendRevokeAndACK_class =
2744                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2745         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2746         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2747         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2748         LDKMessageSendEvent_SendClosingSigned_class =
2749                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2750         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2751         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2752         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2753         LDKMessageSendEvent_SendShutdown_class =
2754                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2755         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2756         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2757         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2758         LDKMessageSendEvent_SendChannelReestablish_class =
2759                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2760         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2761         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2762         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2763         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2764                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2765         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2766         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2767         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2768         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2769                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2770         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2771         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2772         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2773         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2774                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2775         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2776         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2777         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2778         LDKMessageSendEvent_SendChannelUpdate_class =
2779                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2780         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2781         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2782         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2783         LDKMessageSendEvent_HandleError_class =
2784                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2785         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2786         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2787         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2788         LDKMessageSendEvent_SendChannelRangeQuery_class =
2789                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2790         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2791         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2792         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2793         LDKMessageSendEvent_SendShortIdsQuery_class =
2794                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2795         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2796         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2797         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2798         LDKMessageSendEvent_SendReplyChannelRange_class =
2799                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2800         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2801         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2802         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2803         LDKMessageSendEvent_SendGossipTimestampFilter_class =
2804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
2805         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
2806         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
2807         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
2808 }
2809 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2810         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2811         switch(obj->tag) {
2812                 case LDKMessageSendEvent_SendAcceptChannel: {
2813                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2814                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2815                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2816                         int64_t msg_ref = 0;
2817                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2818                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2819                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2820                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2821                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2822                 }
2823                 case LDKMessageSendEvent_SendOpenChannel: {
2824                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2825                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2826                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2827                         int64_t msg_ref = 0;
2828                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2829                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2830                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2831                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2832                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2833                 }
2834                 case LDKMessageSendEvent_SendFundingCreated: {
2835                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2836                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2837                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2838                         int64_t msg_ref = 0;
2839                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2840                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2841                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2842                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2843                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2844                 }
2845                 case LDKMessageSendEvent_SendFundingSigned: {
2846                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2847                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2848                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2849                         int64_t msg_ref = 0;
2850                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2851                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2852                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2853                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2854                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2855                 }
2856                 case LDKMessageSendEvent_SendChannelReady: {
2857                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2858                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
2859                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
2860                         int64_t msg_ref = 0;
2861                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2862                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2863                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2864                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2865                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
2866                 }
2867                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2868                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2869                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2870                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2871                         int64_t msg_ref = 0;
2872                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2873                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2874                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2875                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2876                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2877                 }
2878                 case LDKMessageSendEvent_UpdateHTLCs: {
2879                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2880                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2881                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2882                         int64_t updates_ref = 0;
2883                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2884                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2885                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2886                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2887                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2888                 }
2889                 case LDKMessageSendEvent_SendRevokeAndACK: {
2890                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2891                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2892                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2893                         int64_t msg_ref = 0;
2894                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2895                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2896                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2897                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2898                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2899                 }
2900                 case LDKMessageSendEvent_SendClosingSigned: {
2901                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2902                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2903                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2904                         int64_t msg_ref = 0;
2905                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2906                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2907                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2908                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2909                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2910                 }
2911                 case LDKMessageSendEvent_SendShutdown: {
2912                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2913                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2914                         LDKShutdown msg_var = obj->send_shutdown.msg;
2915                         int64_t msg_ref = 0;
2916                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2917                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2918                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2919                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2920                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2921                 }
2922                 case LDKMessageSendEvent_SendChannelReestablish: {
2923                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2924                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2925                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2926                         int64_t msg_ref = 0;
2927                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2928                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2929                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2930                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2931                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2932                 }
2933                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2934                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2935                         int64_t msg_ref = 0;
2936                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2937                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2938                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2939                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2940                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2941                         int64_t update_msg_ref = 0;
2942                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2943                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2944                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2945                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2946                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2947                 }
2948                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2949                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2950                         int64_t msg_ref = 0;
2951                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2952                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2953                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2954                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2955                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2956                 }
2957                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2958                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2959                         int64_t msg_ref = 0;
2960                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2961                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2962                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2963                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2964                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2965                 }
2966                 case LDKMessageSendEvent_SendChannelUpdate: {
2967                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2968                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
2969                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2970                         int64_t msg_ref = 0;
2971                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2972                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2973                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2974                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2975                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
2976                 }
2977                 case LDKMessageSendEvent_HandleError: {
2978                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2979                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2980                         int64_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2981                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2982                 }
2983                 case LDKMessageSendEvent_SendChannelRangeQuery: {
2984                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2985                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
2986                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2987                         int64_t msg_ref = 0;
2988                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2989                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2990                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2991                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2992                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
2993                 }
2994                 case LDKMessageSendEvent_SendShortIdsQuery: {
2995                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2996                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
2997                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2998                         int64_t msg_ref = 0;
2999                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3000                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3001                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3002                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3003                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3004                 }
3005                 case LDKMessageSendEvent_SendReplyChannelRange: {
3006                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3007                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3008                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3009                         int64_t msg_ref = 0;
3010                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3011                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3012                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3013                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3014                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3015                 }
3016                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3017                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3018                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3019                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3020                         int64_t msg_ref = 0;
3021                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3022                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3023                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3024                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3025                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3026                 }
3027                 default: abort();
3028         }
3029 }
3030 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3031         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3032         for (size_t i = 0; i < ret.datalen; i++) {
3033                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3034         }
3035         return ret;
3036 }
3037 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3038 CHECK(owner->result_ok);
3039         return TxOut_clone(&*owner->contents.result);
3040 }
3041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3042         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3043         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3044         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3045         return (int64_t)ret_ref;
3046 }
3047
3048 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3049 CHECK(!owner->result_ok);
3050         return AccessError_clone(&*owner->contents.err);
3051 }
3052 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3053         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3054         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3055         return ret_conv;
3056 }
3057
3058 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3059         return owner->a;
3060 }
3061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3062         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3063         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3064         return ret_conv;
3065 }
3066
3067 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3068         return owner->b;
3069 }
3070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3071         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
3072         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3073         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3074         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3075         return ret_arr;
3076 }
3077
3078 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3079         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3080         for (size_t i = 0; i < ret.datalen; i++) {
3081                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3082         }
3083         return ret;
3084 }
3085 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
3086         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
3087         for (size_t i = 0; i < ret.datalen; i++) {
3088                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3089         }
3090         return ret;
3091 }
3092 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3093 CHECK(owner->result_ok);
3094         return *owner->contents.result;
3095 }
3096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3097         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3098         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
3099 }
3100
3101 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3102 CHECK(!owner->result_ok);
3103         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
3104 }
3105 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3106         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3107         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
3108         return ret_conv;
3109 }
3110
3111 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3112 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3113 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3114 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3115 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
3116 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
3117 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3118 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3120         LDKMonitorEvent_HTLCEvent_class =
3121                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3122         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3123         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3124         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3125         LDKMonitorEvent_CommitmentTxConfirmed_class =
3126                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3127         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3128         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3129         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3130         LDKMonitorEvent_UpdateCompleted_class =
3131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
3132         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
3133         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
3134         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
3135         LDKMonitorEvent_UpdateFailed_class =
3136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3137         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3138         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3139         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3140 }
3141 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3142         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
3143         switch(obj->tag) {
3144                 case LDKMonitorEvent_HTLCEvent: {
3145                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3146                         int64_t htlc_event_ref = 0;
3147                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3148                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3149                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3150                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
3151                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3152                 }
3153                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3154                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3155                         int64_t commitment_tx_confirmed_ref = 0;
3156                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3157                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3158                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3159                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
3160                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3161                 }
3162                 case LDKMonitorEvent_UpdateCompleted: {
3163                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
3164                         int64_t funding_txo_ref = 0;
3165                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3166                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3167                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3168                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
3169                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
3170                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, monitor_update_id_conv);
3171                 }
3172                 case LDKMonitorEvent_UpdateFailed: {
3173                         LDKOutPoint update_failed_var = obj->update_failed;
3174                         int64_t update_failed_ref = 0;
3175                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3176                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3177                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3178                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
3179                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3180                 }
3181                 default: abort();
3182         }
3183 }
3184 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3185         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3186         for (size_t i = 0; i < ret.datalen; i++) {
3187                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3188         }
3189         return ret;
3190 }
3191 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorEventZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
3192         return OutPoint_clone(&owner->a);
3193 }
3194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3195         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
3196         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_a(owner_conv);
3197         int64_t ret_ref = 0;
3198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3201         ret_ref = (uintptr_t)ret_var.inner;
3202         if (ret_var.is_owned) {
3203                 ret_ref |= 1;
3204         }
3205         return ret_ref;
3206 }
3207
3208 static inline struct LDKCVec_MonitorEventZ C2Tuple_OutPointCVec_MonitorEventZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
3209         return CVec_MonitorEventZ_clone(&owner->b);
3210 }
3211 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3212         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
3213         LDKCVec_MonitorEventZ ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_b(owner_conv);
3214         int64_tArray ret_arr = NULL;
3215         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3216         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3217         for (size_t o = 0; o < ret_var.datalen; o++) {
3218                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3219                 *ret_conv_14_copy = ret_var.data[o];
3220                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
3221                 ret_arr_ptr[o] = ret_conv_14_ref;
3222         }
3223         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3224         FREE(ret_var.data);
3225         return ret_arr;
3226 }
3227
3228 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ *orig) {
3229         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ clone bytes"), .datalen = orig->datalen };
3230         for (size_t i = 0; i < ret.datalen; i++) {
3231                 ret.data[i] = C2Tuple_OutPointCVec_MonitorEventZZ_clone(&orig->data[i]);
3232         }
3233         return ret;
3234 }
3235 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
3236 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
3237 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
3238 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
3239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
3240         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
3241                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
3242         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
3243         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
3244         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
3245         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
3246                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
3247         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
3248         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
3249         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
3250 }
3251 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3252         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3253         switch(obj->tag) {
3254                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
3255                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3256                         *some_conv = obj->some;
3257                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
3258                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((int64_t)some_conv));
3259                 }
3260                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
3261                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
3262                 }
3263                 default: abort();
3264         }
3265 }
3266 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3267 CHECK(owner->result_ok);
3268         return FixedPenaltyScorer_clone(&*owner->contents.result);
3269 }
3270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3271         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3272         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3273         int64_t ret_ref = 0;
3274         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3275         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3277         ret_ref = (uintptr_t)ret_var.inner;
3278         if (ret_var.is_owned) {
3279                 ret_ref |= 1;
3280         }
3281         return ret_ref;
3282 }
3283
3284 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3285 CHECK(!owner->result_ok);
3286         return DecodeError_clone(&*owner->contents.err);
3287 }
3288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3289         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3290         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3291         int64_t ret_ref = 0;
3292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3295         ret_ref = (uintptr_t)ret_var.inner;
3296         if (ret_var.is_owned) {
3297                 ret_ref |= 1;
3298         }
3299         return ret_ref;
3300 }
3301
3302 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3303         return owner->a;
3304 }
3305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3306         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
3307         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
3308         return ret_conv;
3309 }
3310
3311 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3312         return owner->b;
3313 }
3314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3315         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)(owner & ~1);
3316         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
3317         return ret_conv;
3318 }
3319
3320 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
3321 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
3322 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
3323 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
3324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
3325         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
3326                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
3327         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
3328         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
3329         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
3330         LDKCOption_C2Tuple_u64u64ZZ_None_class =
3331                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
3332         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
3333         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
3334         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
3335 }
3336 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3337         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)(ptr & ~1);
3338         switch(obj->tag) {
3339                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
3340                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3341                         *some_conv = obj->some;
3342                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
3343                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, ((int64_t)some_conv));
3344                 }
3345                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
3346                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
3347                 }
3348                 default: abort();
3349         }
3350 }
3351 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
3352         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
3353         for (size_t i = 0; i < ret.datalen; i++) {
3354                 ret.data[i] = NodeId_clone(&orig->data[i]);
3355         }
3356         return ret;
3357 }
3358 typedef struct LDKLogger_JCalls {
3359         atomic_size_t refcnt;
3360         JavaVM *vm;
3361         jweak o;
3362         jmethodID log_meth;
3363 } LDKLogger_JCalls;
3364 static void LDKLogger_JCalls_free(void* this_arg) {
3365         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3366         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3367                 JNIEnv *env;
3368                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3369                 if (get_jenv_res == JNI_EDETACHED) {
3370                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3371                 } else {
3372                         DO_ASSERT(get_jenv_res == JNI_OK);
3373                 }
3374                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3375                 if (get_jenv_res == JNI_EDETACHED) {
3376                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3377                 }
3378                 FREE(j_calls);
3379         }
3380 }
3381 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3382         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3383         JNIEnv *env;
3384         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3385         if (get_jenv_res == JNI_EDETACHED) {
3386                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3387         } else {
3388                 DO_ASSERT(get_jenv_res == JNI_OK);
3389         }
3390         LDKRecord record_var = *record;
3391         int64_t record_ref = 0;
3392         record_var = Record_clone(&record_var);
3393         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3394         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3395         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3396         record_ref = (uintptr_t)record_var.inner;
3397         if (record_var.is_owned) {
3398                 record_ref |= 1;
3399         }
3400         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3401         CHECK(obj != NULL);
3402         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
3403         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3404                 (*env)->ExceptionDescribe(env);
3405                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
3406         }
3407         if (get_jenv_res == JNI_EDETACHED) {
3408                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3409         }
3410 }
3411 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3412         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3413         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3414 }
3415 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
3416         jclass c = (*env)->GetObjectClass(env, o);
3417         CHECK(c != NULL);
3418         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3419         atomic_init(&calls->refcnt, 1);
3420         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3421         calls->o = (*env)->NewWeakGlobalRef(env, o);
3422         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
3423         CHECK(calls->log_meth != NULL);
3424
3425         LDKLogger ret = {
3426                 .this_arg = (void*) calls,
3427                 .log = log_LDKLogger_jcall,
3428                 .free = LDKLogger_JCalls_free,
3429         };
3430         return ret;
3431 }
3432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
3433         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3434         *res_ptr = LDKLogger_init(env, clz, o);
3435         return (uint64_t)res_ptr;
3436 }
3437 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3438 CHECK(owner->result_ok);
3439         return &*owner->contents.result;
3440 }
3441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3442         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3443         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3444         int64_t ret_ref = 0;
3445         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3446         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3448         ret_ref = (uintptr_t)ret_var.inner & ~1;
3449         return ret_ref;
3450 }
3451
3452 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3453 CHECK(!owner->result_ok);
3454         return DecodeError_clone(&*owner->contents.err);
3455 }
3456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3457         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3458         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3459         int64_t ret_ref = 0;
3460         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3461         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3463         ret_ref = (uintptr_t)ret_var.inner;
3464         if (ret_var.is_owned) {
3465                 ret_ref |= 1;
3466         }
3467         return ret_ref;
3468 }
3469
3470 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3471 CHECK(owner->result_ok);
3472         return InitFeatures_clone(&*owner->contents.result);
3473 }
3474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3475         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3476         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3477         int64_t ret_ref = 0;
3478         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3479         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3481         ret_ref = (uintptr_t)ret_var.inner;
3482         if (ret_var.is_owned) {
3483                 ret_ref |= 1;
3484         }
3485         return ret_ref;
3486 }
3487
3488 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3489 CHECK(!owner->result_ok);
3490         return DecodeError_clone(&*owner->contents.err);
3491 }
3492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3493         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3494         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3495         int64_t ret_ref = 0;
3496         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3497         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3499         ret_ref = (uintptr_t)ret_var.inner;
3500         if (ret_var.is_owned) {
3501                 ret_ref |= 1;
3502         }
3503         return ret_ref;
3504 }
3505
3506 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3507 CHECK(owner->result_ok);
3508         return ChannelFeatures_clone(&*owner->contents.result);
3509 }
3510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3511         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3512         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3513         int64_t ret_ref = 0;
3514         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3515         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3517         ret_ref = (uintptr_t)ret_var.inner;
3518         if (ret_var.is_owned) {
3519                 ret_ref |= 1;
3520         }
3521         return ret_ref;
3522 }
3523
3524 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3525 CHECK(!owner->result_ok);
3526         return DecodeError_clone(&*owner->contents.err);
3527 }
3528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3529         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3530         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3531         int64_t ret_ref = 0;
3532         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3533         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3535         ret_ref = (uintptr_t)ret_var.inner;
3536         if (ret_var.is_owned) {
3537                 ret_ref |= 1;
3538         }
3539         return ret_ref;
3540 }
3541
3542 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3543 CHECK(owner->result_ok);
3544         return NodeFeatures_clone(&*owner->contents.result);
3545 }
3546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3547         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3548         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3549         int64_t ret_ref = 0;
3550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3553         ret_ref = (uintptr_t)ret_var.inner;
3554         if (ret_var.is_owned) {
3555                 ret_ref |= 1;
3556         }
3557         return ret_ref;
3558 }
3559
3560 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3561 CHECK(!owner->result_ok);
3562         return DecodeError_clone(&*owner->contents.err);
3563 }
3564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3565         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3566         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3567         int64_t ret_ref = 0;
3568         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3569         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3571         ret_ref = (uintptr_t)ret_var.inner;
3572         if (ret_var.is_owned) {
3573                 ret_ref |= 1;
3574         }
3575         return ret_ref;
3576 }
3577
3578 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3579 CHECK(owner->result_ok);
3580         return InvoiceFeatures_clone(&*owner->contents.result);
3581 }
3582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3583         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3584         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3585         int64_t ret_ref = 0;
3586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3589         ret_ref = (uintptr_t)ret_var.inner;
3590         if (ret_var.is_owned) {
3591                 ret_ref |= 1;
3592         }
3593         return ret_ref;
3594 }
3595
3596 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3597 CHECK(!owner->result_ok);
3598         return DecodeError_clone(&*owner->contents.err);
3599 }
3600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3601         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3602         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3603         int64_t ret_ref = 0;
3604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3607         ret_ref = (uintptr_t)ret_var.inner;
3608         if (ret_var.is_owned) {
3609                 ret_ref |= 1;
3610         }
3611         return ret_ref;
3612 }
3613
3614 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3615 CHECK(owner->result_ok);
3616         return ChannelTypeFeatures_clone(&*owner->contents.result);
3617 }
3618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3619         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3620         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3621         int64_t ret_ref = 0;
3622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3625         ret_ref = (uintptr_t)ret_var.inner;
3626         if (ret_var.is_owned) {
3627                 ret_ref |= 1;
3628         }
3629         return ret_ref;
3630 }
3631
3632 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3633 CHECK(!owner->result_ok);
3634         return DecodeError_clone(&*owner->contents.err);
3635 }
3636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3637         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3638         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3639         int64_t ret_ref = 0;
3640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3643         ret_ref = (uintptr_t)ret_var.inner;
3644         if (ret_var.is_owned) {
3645                 ret_ref |= 1;
3646         }
3647         return ret_ref;
3648 }
3649
3650 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3651 CHECK(owner->result_ok);
3652         return NodeId_clone(&*owner->contents.result);
3653 }
3654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3655         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3656         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3657         int64_t ret_ref = 0;
3658         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3659         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3661         ret_ref = (uintptr_t)ret_var.inner;
3662         if (ret_var.is_owned) {
3663                 ret_ref |= 1;
3664         }
3665         return ret_ref;
3666 }
3667
3668 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3669 CHECK(!owner->result_ok);
3670         return DecodeError_clone(&*owner->contents.err);
3671 }
3672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3673         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3674         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3675         int64_t ret_ref = 0;
3676         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3677         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3679         ret_ref = (uintptr_t)ret_var.inner;
3680         if (ret_var.is_owned) {
3681                 ret_ref |= 1;
3682         }
3683         return ret_ref;
3684 }
3685
3686 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3687 CHECK(owner->result_ok);
3688         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3689 }
3690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3691         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3692         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3693         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3694         int64_t ret_ref = (uintptr_t)ret_copy;
3695         return ret_ref;
3696 }
3697
3698 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3699 CHECK(!owner->result_ok);
3700         return DecodeError_clone(&*owner->contents.err);
3701 }
3702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3703         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3704         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3705         int64_t ret_ref = 0;
3706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3709         ret_ref = (uintptr_t)ret_var.inner;
3710         if (ret_var.is_owned) {
3711                 ret_ref |= 1;
3712         }
3713         return ret_ref;
3714 }
3715
3716 typedef struct LDKAccess_JCalls {
3717         atomic_size_t refcnt;
3718         JavaVM *vm;
3719         jweak o;
3720         jmethodID get_utxo_meth;
3721 } LDKAccess_JCalls;
3722 static void LDKAccess_JCalls_free(void* this_arg) {
3723         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3724         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3725                 JNIEnv *env;
3726                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3727                 if (get_jenv_res == JNI_EDETACHED) {
3728                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3729                 } else {
3730                         DO_ASSERT(get_jenv_res == JNI_OK);
3731                 }
3732                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3733                 if (get_jenv_res == JNI_EDETACHED) {
3734                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3735                 }
3736                 FREE(j_calls);
3737         }
3738 }
3739 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3740         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3741         JNIEnv *env;
3742         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3743         if (get_jenv_res == JNI_EDETACHED) {
3744                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3745         } else {
3746                 DO_ASSERT(get_jenv_res == JNI_OK);
3747         }
3748         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
3749         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
3750         int64_t short_channel_id_conv = short_channel_id;
3751         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3752         CHECK(obj != NULL);
3753         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
3754         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3755                 (*env)->ExceptionDescribe(env);
3756                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
3757         }
3758         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3759         CHECK_ACCESS(ret_ptr);
3760         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3761         FREE((void*)ret);
3762         if (get_jenv_res == JNI_EDETACHED) {
3763                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3764         }
3765         return ret_conv;
3766 }
3767 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3768         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3769         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3770 }
3771 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
3772         jclass c = (*env)->GetObjectClass(env, o);
3773         CHECK(c != NULL);
3774         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3775         atomic_init(&calls->refcnt, 1);
3776         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3777         calls->o = (*env)->NewWeakGlobalRef(env, o);
3778         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
3779         CHECK(calls->get_utxo_meth != NULL);
3780
3781         LDKAccess ret = {
3782                 .this_arg = (void*) calls,
3783                 .get_utxo = get_utxo_LDKAccess_jcall,
3784                 .free = LDKAccess_JCalls_free,
3785         };
3786         return ret;
3787 }
3788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
3789         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3790         *res_ptr = LDKAccess_init(env, clz, o);
3791         return (uint64_t)res_ptr;
3792 }
3793 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) {
3794         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3795         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3796         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3797         unsigned char genesis_hash_arr[32];
3798         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
3799         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
3800         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3801         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3802         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3803         return (int64_t)ret_conv;
3804 }
3805
3806 static jclass LDKCOption_AccessZ_Some_class = NULL;
3807 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
3808 static jclass LDKCOption_AccessZ_None_class = NULL;
3809 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
3810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
3811         LDKCOption_AccessZ_Some_class =
3812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
3813         CHECK(LDKCOption_AccessZ_Some_class != NULL);
3814         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
3815         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
3816         LDKCOption_AccessZ_None_class =
3817                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
3818         CHECK(LDKCOption_AccessZ_None_class != NULL);
3819         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
3820         CHECK(LDKCOption_AccessZ_None_meth != NULL);
3821 }
3822 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3823         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3824         switch(obj->tag) {
3825                 case LDKCOption_AccessZ_Some: {
3826                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3827                         *some_ret = obj->some;
3828                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
3829                         if ((*some_ret).free == LDKAccess_JCalls_free) {
3830                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3831                                 LDKAccess_JCalls_cloned(&(*some_ret));
3832                         }
3833                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (int64_t)some_ret);
3834                 }
3835                 case LDKCOption_AccessZ_None: {
3836                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
3837                 }
3838                 default: abort();
3839         }
3840 }
3841 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3842 CHECK(owner->result_ok);
3843         return *owner->contents.result;
3844 }
3845 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3846         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3847         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
3848         return ret_conv;
3849 }
3850
3851 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3852 CHECK(!owner->result_ok);
3853         return LightningError_clone(&*owner->contents.err);
3854 }
3855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3856         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3857         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3858         int64_t ret_ref = 0;
3859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3862         ret_ref = (uintptr_t)ret_var.inner;
3863         if (ret_var.is_owned) {
3864                 ret_ref |= 1;
3865         }
3866         return ret_ref;
3867 }
3868
3869 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3870         return ChannelAnnouncement_clone(&owner->a);
3871 }
3872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3873         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3874         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3875         int64_t ret_ref = 0;
3876         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3877         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3879         ret_ref = (uintptr_t)ret_var.inner;
3880         if (ret_var.is_owned) {
3881                 ret_ref |= 1;
3882         }
3883         return ret_ref;
3884 }
3885
3886 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3887         return ChannelUpdate_clone(&owner->b);
3888 }
3889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3890         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3891         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3892         int64_t ret_ref = 0;
3893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3896         ret_ref = (uintptr_t)ret_var.inner;
3897         if (ret_var.is_owned) {
3898                 ret_ref |= 1;
3899         }
3900         return ret_ref;
3901 }
3902
3903 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3904         return ChannelUpdate_clone(&owner->c);
3905 }
3906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3907         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3908         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3909         int64_t ret_ref = 0;
3910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3913         ret_ref = (uintptr_t)ret_var.inner;
3914         if (ret_var.is_owned) {
3915                 ret_ref |= 1;
3916         }
3917         return ret_ref;
3918 }
3919
3920 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3921         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3922         for (size_t i = 0; i < ret.datalen; i++) {
3923                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3924         }
3925         return ret;
3926 }
3927 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3928         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3929         for (size_t i = 0; i < ret.datalen; i++) {
3930                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3931         }
3932         return ret;
3933 }
3934 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3935 CHECK(owner->result_ok);
3936         return *owner->contents.result;
3937 }
3938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3939         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3940         CResult_NoneLightningErrorZ_get_ok(owner_conv);
3941 }
3942
3943 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3944 CHECK(!owner->result_ok);
3945         return LightningError_clone(&*owner->contents.err);
3946 }
3947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3948         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3949         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
3950         int64_t ret_ref = 0;
3951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3954         ret_ref = (uintptr_t)ret_var.inner;
3955         if (ret_var.is_owned) {
3956                 ret_ref |= 1;
3957         }
3958         return ret_ref;
3959 }
3960
3961 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3962 CHECK(owner->result_ok);
3963         return ChannelUpdateInfo_clone(&*owner->contents.result);
3964 }
3965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3966         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3967         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
3968         int64_t ret_ref = 0;
3969         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3970         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3972         ret_ref = (uintptr_t)ret_var.inner;
3973         if (ret_var.is_owned) {
3974                 ret_ref |= 1;
3975         }
3976         return ret_ref;
3977 }
3978
3979 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3980 CHECK(!owner->result_ok);
3981         return DecodeError_clone(&*owner->contents.err);
3982 }
3983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3984         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3985         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
3986         int64_t ret_ref = 0;
3987         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3988         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3990         ret_ref = (uintptr_t)ret_var.inner;
3991         if (ret_var.is_owned) {
3992                 ret_ref |= 1;
3993         }
3994         return ret_ref;
3995 }
3996
3997 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3998 CHECK(owner->result_ok);
3999         return ChannelInfo_clone(&*owner->contents.result);
4000 }
4001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4002         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
4003         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4004         int64_t ret_ref = 0;
4005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4008         ret_ref = (uintptr_t)ret_var.inner;
4009         if (ret_var.is_owned) {
4010                 ret_ref |= 1;
4011         }
4012         return ret_ref;
4013 }
4014
4015 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4016 CHECK(!owner->result_ok);
4017         return DecodeError_clone(&*owner->contents.err);
4018 }
4019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4020         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
4021         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4022         int64_t ret_ref = 0;
4023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4026         ret_ref = (uintptr_t)ret_var.inner;
4027         if (ret_var.is_owned) {
4028                 ret_ref |= 1;
4029         }
4030         return ret_ref;
4031 }
4032
4033 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4034 CHECK(owner->result_ok);
4035         return RoutingFees_clone(&*owner->contents.result);
4036 }
4037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4038         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
4039         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4040         int64_t ret_ref = 0;
4041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4044         ret_ref = (uintptr_t)ret_var.inner;
4045         if (ret_var.is_owned) {
4046                 ret_ref |= 1;
4047         }
4048         return ret_ref;
4049 }
4050
4051 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4052 CHECK(!owner->result_ok);
4053         return DecodeError_clone(&*owner->contents.err);
4054 }
4055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4056         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
4057         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4058         int64_t ret_ref = 0;
4059         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4060         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4062         ret_ref = (uintptr_t)ret_var.inner;
4063         if (ret_var.is_owned) {
4064                 ret_ref |= 1;
4065         }
4066         return ret_ref;
4067 }
4068
4069 static jclass LDKNetAddress_IPv4_class = NULL;
4070 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4071 static jclass LDKNetAddress_IPv6_class = NULL;
4072 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4073 static jclass LDKNetAddress_OnionV2_class = NULL;
4074 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4075 static jclass LDKNetAddress_OnionV3_class = NULL;
4076 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4078         LDKNetAddress_IPv4_class =
4079                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4080         CHECK(LDKNetAddress_IPv4_class != NULL);
4081         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4082         CHECK(LDKNetAddress_IPv4_meth != NULL);
4083         LDKNetAddress_IPv6_class =
4084                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4085         CHECK(LDKNetAddress_IPv6_class != NULL);
4086         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4087         CHECK(LDKNetAddress_IPv6_meth != NULL);
4088         LDKNetAddress_OnionV2_class =
4089                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4090         CHECK(LDKNetAddress_OnionV2_class != NULL);
4091         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4092         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4093         LDKNetAddress_OnionV3_class =
4094                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4095         CHECK(LDKNetAddress_OnionV3_class != NULL);
4096         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4097         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4098 }
4099 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4100         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4101         switch(obj->tag) {
4102                 case LDKNetAddress_IPv4: {
4103                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4104                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4105                         int16_t port_conv = obj->i_pv4.port;
4106                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
4107                 }
4108                 case LDKNetAddress_IPv6: {
4109                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4110                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4111                         int16_t port_conv = obj->i_pv6.port;
4112                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
4113                 }
4114                 case LDKNetAddress_OnionV2: {
4115                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4116                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4117                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4118                 }
4119                 case LDKNetAddress_OnionV3: {
4120                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4121                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4122                         int16_t checksum_conv = obj->onion_v3.checksum;
4123                         int8_t version_conv = obj->onion_v3.version;
4124                         int16_t port_conv = obj->onion_v3.port;
4125                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
4126                 }
4127                 default: abort();
4128         }
4129 }
4130 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4131         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4132         for (size_t i = 0; i < ret.datalen; i++) {
4133                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4134         }
4135         return ret;
4136 }
4137 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4138 CHECK(owner->result_ok);
4139         return NodeAnnouncementInfo_clone(&*owner->contents.result);
4140 }
4141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4142         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4143         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4144         int64_t ret_ref = 0;
4145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4148         ret_ref = (uintptr_t)ret_var.inner;
4149         if (ret_var.is_owned) {
4150                 ret_ref |= 1;
4151         }
4152         return ret_ref;
4153 }
4154
4155 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4156 CHECK(!owner->result_ok);
4157         return DecodeError_clone(&*owner->contents.err);
4158 }
4159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4160         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
4161         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4162         int64_t ret_ref = 0;
4163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4166         ret_ref = (uintptr_t)ret_var.inner;
4167         if (ret_var.is_owned) {
4168                 ret_ref |= 1;
4169         }
4170         return ret_ref;
4171 }
4172
4173 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4174 CHECK(owner->result_ok);
4175         return NodeAlias_clone(&*owner->contents.result);
4176 }
4177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4178         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
4179         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4180         int64_t ret_ref = 0;
4181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4184         ret_ref = (uintptr_t)ret_var.inner;
4185         if (ret_var.is_owned) {
4186                 ret_ref |= 1;
4187         }
4188         return ret_ref;
4189 }
4190
4191 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4192 CHECK(!owner->result_ok);
4193         return DecodeError_clone(&*owner->contents.err);
4194 }
4195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4196         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(owner & ~1);
4197         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4198         int64_t ret_ref = 0;
4199         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4200         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4202         ret_ref = (uintptr_t)ret_var.inner;
4203         if (ret_var.is_owned) {
4204                 ret_ref |= 1;
4205         }
4206         return ret_ref;
4207 }
4208
4209 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
4210         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
4211         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
4212         return ret;
4213 }
4214 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4215 CHECK(owner->result_ok);
4216         return NodeInfo_clone(&*owner->contents.result);
4217 }
4218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4219         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4220         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4221         int64_t ret_ref = 0;
4222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4225         ret_ref = (uintptr_t)ret_var.inner;
4226         if (ret_var.is_owned) {
4227                 ret_ref |= 1;
4228         }
4229         return ret_ref;
4230 }
4231
4232 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4233 CHECK(!owner->result_ok);
4234         return DecodeError_clone(&*owner->contents.err);
4235 }
4236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4237         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
4238         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4239         int64_t ret_ref = 0;
4240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4243         ret_ref = (uintptr_t)ret_var.inner;
4244         if (ret_var.is_owned) {
4245                 ret_ref |= 1;
4246         }
4247         return ret_ref;
4248 }
4249
4250 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4251 CHECK(owner->result_ok);
4252         return &*owner->contents.result;
4253 }
4254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4255         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4256         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4257         int64_t ret_ref = 0;
4258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4261         ret_ref = (uintptr_t)ret_var.inner & ~1;
4262         return ret_ref;
4263 }
4264
4265 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4266 CHECK(!owner->result_ok);
4267         return DecodeError_clone(&*owner->contents.err);
4268 }
4269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4270         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
4271         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4272         int64_t ret_ref = 0;
4273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4276         ret_ref = (uintptr_t)ret_var.inner;
4277         if (ret_var.is_owned) {
4278                 ret_ref |= 1;
4279         }
4280         return ret_ref;
4281 }
4282
4283 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4284 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4285 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4286 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4288         LDKCOption_CVec_NetAddressZZ_Some_class =
4289                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4290         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4291         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4292         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4293         LDKCOption_CVec_NetAddressZZ_None_class =
4294                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4295         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4296         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4297         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4298 }
4299 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4300         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4301         switch(obj->tag) {
4302                 case LDKCOption_CVec_NetAddressZZ_Some: {
4303                         LDKCVec_NetAddressZ some_var = obj->some;
4304                         int64_tArray some_arr = NULL;
4305                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4306                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4307                         for (size_t m = 0; m < some_var.datalen; m++) {
4308                                 int64_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
4309                                 some_arr_ptr[m] = some_conv_12_ref;
4310                         }
4311                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4312                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4313                 }
4314                 case LDKCOption_CVec_NetAddressZZ_None: {
4315                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
4316                 }
4317                 default: abort();
4318         }
4319 }
4320 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4321 CHECK(owner->result_ok);
4322         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
4323 }
4324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4325         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4326         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4327         int64_t ret_ref = 0;
4328         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4329         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4331         ret_ref = (uintptr_t)ret_var.inner;
4332         if (ret_var.is_owned) {
4333                 ret_ref |= 1;
4334         }
4335         return ret_ref;
4336 }
4337
4338 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4339 CHECK(!owner->result_ok);
4340         return DecodeError_clone(&*owner->contents.err);
4341 }
4342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4343         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4344         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4345         int64_t ret_ref = 0;
4346         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4347         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4349         ret_ref = (uintptr_t)ret_var.inner;
4350         if (ret_var.is_owned) {
4351                 ret_ref |= 1;
4352         }
4353         return ret_ref;
4354 }
4355
4356 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4357 CHECK(owner->result_ok);
4358         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
4359 }
4360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4361         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4362         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4363         int64_t ret_ref = 0;
4364         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4365         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4367         ret_ref = (uintptr_t)ret_var.inner;
4368         if (ret_var.is_owned) {
4369                 ret_ref |= 1;
4370         }
4371         return ret_ref;
4372 }
4373
4374 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4375 CHECK(!owner->result_ok);
4376         return DecodeError_clone(&*owner->contents.err);
4377 }
4378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4379         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
4380         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4381         int64_t ret_ref = 0;
4382         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4383         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4385         ret_ref = (uintptr_t)ret_var.inner;
4386         if (ret_var.is_owned) {
4387                 ret_ref |= 1;
4388         }
4389         return ret_ref;
4390 }
4391
4392 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4393 CHECK(owner->result_ok);
4394         return SpendableOutputDescriptor_clone(&*owner->contents.result);
4395 }
4396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4397         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4398         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
4399         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4400         int64_t ret_ref = (uintptr_t)ret_copy;
4401         return ret_ref;
4402 }
4403
4404 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4405 CHECK(!owner->result_ok);
4406         return DecodeError_clone(&*owner->contents.err);
4407 }
4408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4409         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
4410         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4411         int64_t ret_ref = 0;
4412         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4413         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4415         ret_ref = (uintptr_t)ret_var.inner;
4416         if (ret_var.is_owned) {
4417                 ret_ref |= 1;
4418         }
4419         return ret_ref;
4420 }
4421
4422 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
4423         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
4424         for (size_t i = 0; i < ret.datalen; i++) {
4425                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4426         }
4427         return ret;
4428 }
4429 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4430         return owner->a;
4431 }
4432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4433         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4434         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4435         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
4436         return ret_arr;
4437 }
4438
4439 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4440         return owner->b;
4441 }
4442 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4443         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
4444         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
4445         jobjectArray ret_arr = NULL;
4446         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4447         ;
4448         for (size_t i = 0; i < ret_var.datalen; i++) {
4449                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
4450                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
4451                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4452         }
4453         
4454         return ret_arr;
4455 }
4456
4457 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4458 CHECK(owner->result_ok);
4459         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
4460 }
4461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4462         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4463         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4464         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
4465         return ((int64_t)ret_conv);
4466 }
4467
4468 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
4469 CHECK(!owner->result_ok);
4470         return *owner->contents.err;
4471 }
4472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4473         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
4474         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
4475 }
4476
4477 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4478 CHECK(owner->result_ok);
4479         return *owner->contents.result;
4480 }
4481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4482         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4483         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4484         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
4485         return ret_arr;
4486 }
4487
4488 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
4489 CHECK(!owner->result_ok);
4490         return *owner->contents.err;
4491 }
4492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4493         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
4494         CResult_SignatureNoneZ_get_err(owner_conv);
4495 }
4496
4497 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4498         return owner->a;
4499 }
4500 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4501         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4502         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4503         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
4504         return ret_arr;
4505 }
4506
4507 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
4508         return owner->b;
4509 }
4510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4511         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
4512         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4513         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
4514         return ret_arr;
4515 }
4516
4517 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4518 CHECK(owner->result_ok);
4519         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
4520 }
4521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4522         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4523         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
4524         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
4525         return ((int64_t)ret_conv);
4526 }
4527
4528 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
4529 CHECK(!owner->result_ok);
4530         return *owner->contents.err;
4531 }
4532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4533         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
4534         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
4535 }
4536
4537 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4538 CHECK(owner->result_ok);
4539         return *owner->contents.result;
4540 }
4541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4542         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4543         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4544         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
4545         return ret_arr;
4546 }
4547
4548 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
4549 CHECK(!owner->result_ok);
4550         return *owner->contents.err;
4551 }
4552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4553         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
4554         CResult_SecretKeyNoneZ_get_err(owner_conv);
4555 }
4556
4557 typedef struct LDKBaseSign_JCalls {
4558         atomic_size_t refcnt;
4559         JavaVM *vm;
4560         jweak o;
4561         jmethodID get_per_commitment_point_meth;
4562         jmethodID release_commitment_secret_meth;
4563         jmethodID validate_holder_commitment_meth;
4564         jmethodID channel_keys_id_meth;
4565         jmethodID sign_counterparty_commitment_meth;
4566         jmethodID validate_counterparty_revocation_meth;
4567         jmethodID sign_holder_commitment_and_htlcs_meth;
4568         jmethodID sign_justice_revoked_output_meth;
4569         jmethodID sign_justice_revoked_htlc_meth;
4570         jmethodID sign_counterparty_htlc_transaction_meth;
4571         jmethodID sign_closing_transaction_meth;
4572         jmethodID sign_channel_announcement_meth;
4573         jmethodID ready_channel_meth;
4574 } LDKBaseSign_JCalls;
4575 static void LDKBaseSign_JCalls_free(void* this_arg) {
4576         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4577         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4578                 JNIEnv *env;
4579                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4580                 if (get_jenv_res == JNI_EDETACHED) {
4581                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4582                 } else {
4583                         DO_ASSERT(get_jenv_res == JNI_OK);
4584                 }
4585                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4586                 if (get_jenv_res == JNI_EDETACHED) {
4587                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4588                 }
4589                 FREE(j_calls);
4590         }
4591 }
4592 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4593         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4594         JNIEnv *env;
4595         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4596         if (get_jenv_res == JNI_EDETACHED) {
4597                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4598         } else {
4599                 DO_ASSERT(get_jenv_res == JNI_OK);
4600         }
4601         int64_t idx_conv = idx;
4602         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4603         CHECK(obj != NULL);
4604         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
4605         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4606                 (*env)->ExceptionDescribe(env);
4607                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
4608         }
4609         LDKPublicKey ret_ref;
4610         CHECK((*env)->GetArrayLength(env, ret) == 33);
4611         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
4612         if (get_jenv_res == JNI_EDETACHED) {
4613                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4614         }
4615         return ret_ref;
4616 }
4617 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
4618         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4619         JNIEnv *env;
4620         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4621         if (get_jenv_res == JNI_EDETACHED) {
4622                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4623         } else {
4624                 DO_ASSERT(get_jenv_res == JNI_OK);
4625         }
4626         int64_t idx_conv = idx;
4627         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4628         CHECK(obj != NULL);
4629         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
4630         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4631                 (*env)->ExceptionDescribe(env);
4632                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
4633         }
4634         LDKThirtyTwoBytes ret_ref;
4635         CHECK((*env)->GetArrayLength(env, ret) == 32);
4636         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4637         if (get_jenv_res == JNI_EDETACHED) {
4638                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4639         }
4640         return ret_ref;
4641 }
4642 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
4643         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4644         JNIEnv *env;
4645         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4646         if (get_jenv_res == JNI_EDETACHED) {
4647                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4648         } else {
4649                 DO_ASSERT(get_jenv_res == JNI_OK);
4650         }
4651         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
4652         int64_t holder_tx_ref = 0;
4653         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
4654         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4655         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4656         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
4657         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
4658         if (holder_tx_var.is_owned) {
4659                 holder_tx_ref |= 1;
4660         }
4661         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4662         jobjectArray preimages_arr = NULL;
4663         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4664         ;
4665         for (size_t i = 0; i < preimages_var.datalen; i++) {
4666                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4667                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4668                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4669         }
4670         
4671         FREE(preimages_var.data);
4672         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4673         CHECK(obj != NULL);
4674         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
4675         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4676                 (*env)->ExceptionDescribe(env);
4677                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
4678         }
4679         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4680         CHECK_ACCESS(ret_ptr);
4681         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4682         FREE((void*)ret);
4683         if (get_jenv_res == JNI_EDETACHED) {
4684                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4685         }
4686         return ret_conv;
4687 }
4688 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
4689         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4690         JNIEnv *env;
4691         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4692         if (get_jenv_res == JNI_EDETACHED) {
4693                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4694         } else {
4695                 DO_ASSERT(get_jenv_res == JNI_OK);
4696         }
4697         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4698         CHECK(obj != NULL);
4699         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
4700         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4701                 (*env)->ExceptionDescribe(env);
4702                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
4703         }
4704         LDKThirtyTwoBytes ret_ref;
4705         CHECK((*env)->GetArrayLength(env, ret) == 32);
4706         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4707         if (get_jenv_res == JNI_EDETACHED) {
4708                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4709         }
4710         return ret_ref;
4711 }
4712 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
4713         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4714         JNIEnv *env;
4715         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4716         if (get_jenv_res == JNI_EDETACHED) {
4717                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4718         } else {
4719                 DO_ASSERT(get_jenv_res == JNI_OK);
4720         }
4721         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
4722         int64_t commitment_tx_ref = 0;
4723         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
4724         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4725         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4726         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4727         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4728         if (commitment_tx_var.is_owned) {
4729                 commitment_tx_ref |= 1;
4730         }
4731         LDKCVec_PaymentPreimageZ preimages_var = preimages;
4732         jobjectArray preimages_arr = NULL;
4733         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
4734         ;
4735         for (size_t i = 0; i < preimages_var.datalen; i++) {
4736                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
4737                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
4738                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
4739         }
4740         
4741         FREE(preimages_var.data);
4742         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4743         CHECK(obj != NULL);
4744         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
4745         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4746                 (*env)->ExceptionDescribe(env);
4747                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
4748         }
4749         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4750         CHECK_ACCESS(ret_ptr);
4751         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4752         FREE((void*)ret);
4753         if (get_jenv_res == JNI_EDETACHED) {
4754                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4755         }
4756         return ret_conv;
4757 }
4758 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
4759         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4760         JNIEnv *env;
4761         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4762         if (get_jenv_res == JNI_EDETACHED) {
4763                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4764         } else {
4765                 DO_ASSERT(get_jenv_res == JNI_OK);
4766         }
4767         int64_t idx_conv = idx;
4768         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
4769         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
4770         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4771         CHECK(obj != NULL);
4772         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
4773         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4774                 (*env)->ExceptionDescribe(env);
4775                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
4776         }
4777         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4778         CHECK_ACCESS(ret_ptr);
4779         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
4780         FREE((void*)ret);
4781         if (get_jenv_res == JNI_EDETACHED) {
4782                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4783         }
4784         return ret_conv;
4785 }
4786 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
4787         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4788         JNIEnv *env;
4789         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4790         if (get_jenv_res == JNI_EDETACHED) {
4791                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4792         } else {
4793                 DO_ASSERT(get_jenv_res == JNI_OK);
4794         }
4795         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
4796         int64_t commitment_tx_ref = 0;
4797         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
4798         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4799         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4800         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
4801         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
4802         if (commitment_tx_var.is_owned) {
4803                 commitment_tx_ref |= 1;
4804         }
4805         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4806         CHECK(obj != NULL);
4807         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
4808         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4809                 (*env)->ExceptionDescribe(env);
4810                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
4811         }
4812         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4813         CHECK_ACCESS(ret_ptr);
4814         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
4815         FREE((void*)ret);
4816         if (get_jenv_res == JNI_EDETACHED) {
4817                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4818         }
4819         return ret_conv;
4820 }
4821 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]) {
4822         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4823         JNIEnv *env;
4824         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4825         if (get_jenv_res == JNI_EDETACHED) {
4826                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4827         } else {
4828                 DO_ASSERT(get_jenv_res == JNI_OK);
4829         }
4830         LDKTransaction justice_tx_var = justice_tx;
4831         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
4832         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
4833         Transaction_free(justice_tx_var);
4834         int64_t input_conv = input;
4835         int64_t amount_conv = amount;
4836         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
4837         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
4838         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4839         CHECK(obj != NULL);
4840         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);
4841         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4842                 (*env)->ExceptionDescribe(env);
4843                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
4844         }
4845         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4846         CHECK_ACCESS(ret_ptr);
4847         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4848         FREE((void*)ret);
4849         if (get_jenv_res == JNI_EDETACHED) {
4850                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4851         }
4852         return ret_conv;
4853 }
4854 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) {
4855         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4856         JNIEnv *env;
4857         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4858         if (get_jenv_res == JNI_EDETACHED) {
4859                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4860         } else {
4861                 DO_ASSERT(get_jenv_res == JNI_OK);
4862         }
4863         LDKTransaction justice_tx_var = justice_tx;
4864         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
4865         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
4866         Transaction_free(justice_tx_var);
4867         int64_t input_conv = input;
4868         int64_t amount_conv = amount;
4869         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
4870         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
4871         LDKHTLCOutputInCommitment htlc_var = *htlc;
4872         int64_t htlc_ref = 0;
4873         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4874         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4875         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4876         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4877         htlc_ref = (uintptr_t)htlc_var.inner;
4878         if (htlc_var.is_owned) {
4879                 htlc_ref |= 1;
4880         }
4881         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4882         CHECK(obj != NULL);
4883         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);
4884         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4885                 (*env)->ExceptionDescribe(env);
4886                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
4887         }
4888         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4889         CHECK_ACCESS(ret_ptr);
4890         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4891         FREE((void*)ret);
4892         if (get_jenv_res == JNI_EDETACHED) {
4893                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4894         }
4895         return ret_conv;
4896 }
4897 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) {
4898         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4899         JNIEnv *env;
4900         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4901         if (get_jenv_res == JNI_EDETACHED) {
4902                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4903         } else {
4904                 DO_ASSERT(get_jenv_res == JNI_OK);
4905         }
4906         LDKTransaction htlc_tx_var = htlc_tx;
4907         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
4908         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
4909         Transaction_free(htlc_tx_var);
4910         int64_t input_conv = input;
4911         int64_t amount_conv = amount;
4912         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
4913         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
4914         LDKHTLCOutputInCommitment htlc_var = *htlc;
4915         int64_t htlc_ref = 0;
4916         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4917         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4918         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4919         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4920         htlc_ref = (uintptr_t)htlc_var.inner;
4921         if (htlc_var.is_owned) {
4922                 htlc_ref |= 1;
4923         }
4924         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4925         CHECK(obj != NULL);
4926         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);
4927         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4928                 (*env)->ExceptionDescribe(env);
4929                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
4930         }
4931         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4932         CHECK_ACCESS(ret_ptr);
4933         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4934         FREE((void*)ret);
4935         if (get_jenv_res == JNI_EDETACHED) {
4936                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4937         }
4938         return ret_conv;
4939 }
4940 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
4941         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4942         JNIEnv *env;
4943         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4944         if (get_jenv_res == JNI_EDETACHED) {
4945                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4946         } else {
4947                 DO_ASSERT(get_jenv_res == JNI_OK);
4948         }
4949         LDKClosingTransaction closing_tx_var = *closing_tx;
4950         int64_t closing_tx_ref = 0;
4951         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
4952         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4953         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4954         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
4955         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
4956         if (closing_tx_var.is_owned) {
4957                 closing_tx_ref |= 1;
4958         }
4959         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4960         CHECK(obj != NULL);
4961         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
4962         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4963                 (*env)->ExceptionDescribe(env);
4964                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
4965         }
4966         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4967         CHECK_ACCESS(ret_ptr);
4968         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4969         FREE((void*)ret);
4970         if (get_jenv_res == JNI_EDETACHED) {
4971                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4972         }
4973         return ret_conv;
4974 }
4975 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4976         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4977         JNIEnv *env;
4978         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4979         if (get_jenv_res == JNI_EDETACHED) {
4980                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4981         } else {
4982                 DO_ASSERT(get_jenv_res == JNI_OK);
4983         }
4984         LDKUnsignedChannelAnnouncement msg_var = *msg;
4985         int64_t msg_ref = 0;
4986         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
4987         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4988         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4989         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4990         msg_ref = (uintptr_t)msg_var.inner;
4991         if (msg_var.is_owned) {
4992                 msg_ref |= 1;
4993         }
4994         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4995         CHECK(obj != NULL);
4996         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
4997         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4998                 (*env)->ExceptionDescribe(env);
4999                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
5000         }
5001         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5002         CHECK_ACCESS(ret_ptr);
5003         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
5004         FREE((void*)ret);
5005         if (get_jenv_res == JNI_EDETACHED) {
5006                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5007         }
5008         return ret_conv;
5009 }
5010 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5011         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5012         JNIEnv *env;
5013         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5014         if (get_jenv_res == JNI_EDETACHED) {
5015                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5016         } else {
5017                 DO_ASSERT(get_jenv_res == JNI_OK);
5018         }
5019         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5020         int64_t channel_parameters_ref = 0;
5021         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5022         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5023         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5024         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5025         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
5026         if (channel_parameters_var.is_owned) {
5027                 channel_parameters_ref |= 1;
5028         }
5029         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5030         CHECK(obj != NULL);
5031         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
5032         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5033                 (*env)->ExceptionDescribe(env);
5034                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
5035         }
5036         if (get_jenv_res == JNI_EDETACHED) {
5037                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5038         }
5039 }
5040 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5041         jclass c = (*env)->GetObjectClass(env, o);
5042         CHECK(c != NULL);
5043         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
5044         atomic_init(&calls->refcnt, 1);
5045         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5046         calls->o = (*env)->NewWeakGlobalRef(env, o);
5047         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5048         CHECK(calls->get_per_commitment_point_meth != NULL);
5049         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5050         CHECK(calls->release_commitment_secret_meth != NULL);
5051         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5052         CHECK(calls->validate_holder_commitment_meth != NULL);
5053         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5054         CHECK(calls->channel_keys_id_meth != NULL);
5055         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
5056         CHECK(calls->sign_counterparty_commitment_meth != NULL);
5057         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
5058         CHECK(calls->validate_counterparty_revocation_meth != NULL);
5059         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
5060         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
5061         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
5062         CHECK(calls->sign_justice_revoked_output_meth != NULL);
5063         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
5064         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
5065         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
5066         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
5067         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
5068         CHECK(calls->sign_closing_transaction_meth != NULL);
5069         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
5070         CHECK(calls->sign_channel_announcement_meth != NULL);
5071         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
5072         CHECK(calls->ready_channel_meth != NULL);
5073
5074         LDKChannelPublicKeys pubkeys_conv;
5075         pubkeys_conv.inner = (void*)(pubkeys & (~1));
5076         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
5077         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5078
5079         LDKBaseSign ret = {
5080                 .this_arg = (void*) calls,
5081                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
5082                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
5083                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
5084                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
5085                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
5086                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
5087                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
5088                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
5089                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
5090                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
5091                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
5092                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
5093                 .ready_channel = ready_channel_LDKBaseSign_jcall,
5094                 .free = LDKBaseSign_JCalls_free,
5095                 .pubkeys = pubkeys_conv,
5096                 .set_pubkeys = NULL,
5097         };
5098         return ret;
5099 }
5100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5101         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
5102         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
5103         return (uint64_t)res_ptr;
5104 }
5105 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) {
5106         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5107         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5108         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5109         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5110         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5111         return ret_arr;
5112 }
5113
5114 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5115         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5116         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5117         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5118         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5119         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5120         return ret_arr;
5121 }
5122
5123 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) {
5124         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5125         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5126         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5127         LDKHolderCommitmentTransaction holder_tx_conv;
5128         holder_tx_conv.inner = (void*)(holder_tx & (~1));
5129         holder_tx_conv.is_owned = false;
5130         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5131         LDKCVec_PaymentPreimageZ preimages_constr;
5132         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5133         if (preimages_constr.datalen > 0)
5134                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5135         else
5136                 preimages_constr.data = NULL;
5137         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5138                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5139                 LDKThirtyTwoBytes preimages_conv_8_ref;
5140                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5141                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5142                 preimages_constr.data[i] = preimages_conv_8_ref;
5143         }
5144         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5145         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5146         return (int64_t)ret_conv;
5147 }
5148
5149 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5150         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5151         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5152         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5153         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5154         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5155         return ret_arr;
5156 }
5157
5158 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) {
5159         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5160         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5161         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5162         LDKCommitmentTransaction commitment_tx_conv;
5163         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5164         commitment_tx_conv.is_owned = false;
5165         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5166         LDKCVec_PaymentPreimageZ preimages_constr;
5167         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5168         if (preimages_constr.datalen > 0)
5169                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5170         else
5171                 preimages_constr.data = NULL;
5172         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5173                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5174                 LDKThirtyTwoBytes preimages_conv_8_ref;
5175                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5176                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5177                 preimages_constr.data[i] = preimages_conv_8_ref;
5178         }
5179         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5180         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
5181         return (int64_t)ret_conv;
5182 }
5183
5184 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) {
5185         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5186         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5187         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5188         unsigned char secret_arr[32];
5189         CHECK((*env)->GetArrayLength(env, secret) == 32);
5190         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
5191         unsigned char (*secret_ref)[32] = &secret_arr;
5192         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5193         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
5194         return (int64_t)ret_conv;
5195 }
5196
5197 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) {
5198         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5199         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5200         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5201         LDKHolderCommitmentTransaction commitment_tx_conv;
5202         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
5203         commitment_tx_conv.is_owned = false;
5204         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5205         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5206         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
5207         return (int64_t)ret_conv;
5208 }
5209
5210 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) {
5211         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5212         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5213         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5214         LDKTransaction justice_tx_ref;
5215         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5216         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5217         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5218         justice_tx_ref.data_is_owned = true;
5219         unsigned char per_commitment_key_arr[32];
5220         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5221         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5222         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5223         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5224         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
5225         return (int64_t)ret_conv;
5226 }
5227
5228 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) {
5229         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5230         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5231         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5232         LDKTransaction justice_tx_ref;
5233         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5234         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5235         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5236         justice_tx_ref.data_is_owned = true;
5237         unsigned char per_commitment_key_arr[32];
5238         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5239         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5240         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5241         LDKHTLCOutputInCommitment htlc_conv;
5242         htlc_conv.inner = (void*)(htlc & (~1));
5243         htlc_conv.is_owned = false;
5244         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5245         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5246         *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);
5247         return (int64_t)ret_conv;
5248 }
5249
5250 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) {
5251         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5252         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5253         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5254         LDKTransaction htlc_tx_ref;
5255         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
5256         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
5257         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
5258         htlc_tx_ref.data_is_owned = true;
5259         LDKPublicKey per_commitment_point_ref;
5260         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
5261         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
5262         LDKHTLCOutputInCommitment htlc_conv;
5263         htlc_conv.inner = (void*)(htlc & (~1));
5264         htlc_conv.is_owned = false;
5265         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5266         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5267         *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);
5268         return (int64_t)ret_conv;
5269 }
5270
5271 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) {
5272         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5273         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5274         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5275         LDKClosingTransaction closing_tx_conv;
5276         closing_tx_conv.inner = (void*)(closing_tx & (~1));
5277         closing_tx_conv.is_owned = false;
5278         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
5279         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5280         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
5281         return (int64_t)ret_conv;
5282 }
5283
5284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5285         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5286         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5287         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5288         LDKUnsignedChannelAnnouncement msg_conv;
5289         msg_conv.inner = (void*)(msg & (~1));
5290         msg_conv.is_owned = false;
5291         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
5292         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
5293         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5294         return (int64_t)ret_conv;
5295 }
5296
5297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
5298         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5299         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5300         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5301         LDKChannelTransactionParameters channel_parameters_conv;
5302         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
5303         channel_parameters_conv.is_owned = false;
5304         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
5305         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
5306 }
5307
5308 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
5309         if (this_arg->set_pubkeys != NULL)
5310                 this_arg->set_pubkeys(this_arg);
5311         return this_arg->pubkeys;
5312 }
5313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
5314         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5315         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5316         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5317         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
5318         int64_t ret_ref = 0;
5319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5322         ret_ref = (uintptr_t)ret_var.inner;
5323         if (ret_var.is_owned) {
5324                 ret_ref |= 1;
5325         }
5326         return ret_ref;
5327 }
5328
5329 typedef struct LDKSign_JCalls {
5330         atomic_size_t refcnt;
5331         JavaVM *vm;
5332         jweak o;
5333         LDKBaseSign_JCalls* BaseSign;
5334         jmethodID write_meth;
5335 } LDKSign_JCalls;
5336 static void LDKSign_JCalls_free(void* this_arg) {
5337         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5338         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5339                 JNIEnv *env;
5340                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5341                 if (get_jenv_res == JNI_EDETACHED) {
5342                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5343                 } else {
5344                         DO_ASSERT(get_jenv_res == JNI_OK);
5345                 }
5346                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5347                 if (get_jenv_res == JNI_EDETACHED) {
5348                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5349                 }
5350                 FREE(j_calls);
5351         }
5352 }
5353 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
5354         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5355         JNIEnv *env;
5356         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5357         if (get_jenv_res == JNI_EDETACHED) {
5358                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5359         } else {
5360                 DO_ASSERT(get_jenv_res == JNI_OK);
5361         }
5362         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5363         CHECK(obj != NULL);
5364         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5365         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5366                 (*env)->ExceptionDescribe(env);
5367                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
5368         }
5369         LDKCVec_u8Z ret_ref;
5370         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5371         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5372         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5373         if (get_jenv_res == JNI_EDETACHED) {
5374                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5375         }
5376         return ret_ref;
5377 }
5378 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
5379         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
5380         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5381         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
5382 }
5383 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5384         jclass c = (*env)->GetObjectClass(env, o);
5385         CHECK(c != NULL);
5386         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
5387         atomic_init(&calls->refcnt, 1);
5388         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5389         calls->o = (*env)->NewWeakGlobalRef(env, o);
5390         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
5391         CHECK(calls->write_meth != NULL);
5392
5393         LDKChannelPublicKeys pubkeys_conv;
5394         pubkeys_conv.inner = (void*)(pubkeys & (~1));
5395         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
5396         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5397
5398         LDKSign ret = {
5399                 .this_arg = (void*) calls,
5400                 .write = write_LDKSign_jcall,
5401                 .cloned = LDKSign_JCalls_cloned,
5402                 .free = LDKSign_JCalls_free,
5403                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
5404         };
5405         calls->BaseSign = ret.BaseSign.this_arg;
5406         return ret;
5407 }
5408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5409         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
5410         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
5411         return (uint64_t)res_ptr;
5412 }
5413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
5414         LDKSign *inp = (LDKSign *)(arg & ~1);
5415         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
5416         DO_ASSERT((res_ptr & 1) == 0);
5417         return (int64_t)(res_ptr | 1);
5418 }
5419 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5420         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5421         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5422         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
5423         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5424         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5425         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5426         CVec_u8Z_free(ret_var);
5427         return ret_arr;
5428 }
5429
5430 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5431 CHECK(owner->result_ok);
5432         return Sign_clone(&*owner->contents.result);
5433 }
5434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5435         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5436         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5437         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
5438         return (int64_t)ret_ret;
5439 }
5440
5441 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5442 CHECK(!owner->result_ok);
5443         return DecodeError_clone(&*owner->contents.err);
5444 }
5445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5446         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5447         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
5448         int64_t ret_ref = 0;
5449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5452         ret_ref = (uintptr_t)ret_var.inner;
5453         if (ret_var.is_owned) {
5454                 ret_ref |= 1;
5455         }
5456         return ret_ref;
5457 }
5458
5459 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5460 CHECK(owner->result_ok);
5461         return *owner->contents.result;
5462 }
5463 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5464         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5465         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
5466         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
5467         return ret_arr;
5468 }
5469
5470 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5471 CHECK(!owner->result_ok);
5472         return *owner->contents.err;
5473 }
5474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5475         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5476         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5477 }
5478
5479 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
5480         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
5481         for (size_t i = 0; i < ret.datalen; i++) {
5482                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
5483         }
5484         return ret;
5485 }
5486 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5487 CHECK(owner->result_ok);
5488         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
5489 }
5490 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5491         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5492         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
5493         jobjectArray ret_arr = NULL;
5494         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5495         ;
5496         for (size_t i = 0; i < ret_var.datalen; i++) {
5497                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
5498                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
5499                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
5500                 CVec_u8Z_free(ret_conv_8_var);
5501                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5502         }
5503         
5504         FREE(ret_var.data);
5505         return ret_arr;
5506 }
5507
5508 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5509 CHECK(!owner->result_ok);
5510         return *owner->contents.err;
5511 }
5512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5513         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5514         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
5515 }
5516
5517 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5518 CHECK(owner->result_ok);
5519         return InMemorySigner_clone(&*owner->contents.result);
5520 }
5521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5522         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5523         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
5524         int64_t ret_ref = 0;
5525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5528         ret_ref = (uintptr_t)ret_var.inner;
5529         if (ret_var.is_owned) {
5530                 ret_ref |= 1;
5531         }
5532         return ret_ref;
5533 }
5534
5535 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5536 CHECK(!owner->result_ok);
5537         return DecodeError_clone(&*owner->contents.err);
5538 }
5539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5540         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5541         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
5542         int64_t ret_ref = 0;
5543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5546         ret_ref = (uintptr_t)ret_var.inner;
5547         if (ret_var.is_owned) {
5548                 ret_ref |= 1;
5549         }
5550         return ret_ref;
5551 }
5552
5553 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
5554         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
5555         for (size_t i = 0; i < ret.datalen; i++) {
5556                 ret.data[i] = TxOut_clone(&orig->data[i]);
5557         }
5558         return ret;
5559 }
5560 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5561 CHECK(owner->result_ok);
5562         return *owner->contents.result;
5563 }
5564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5565         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5566         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
5567         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5568         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5569         return ret_arr;
5570 }
5571
5572 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5573 CHECK(!owner->result_ok);
5574         return *owner->contents.err;
5575 }
5576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5577         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5578         CResult_TransactionNoneZ_get_err(owner_conv);
5579 }
5580
5581 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5582         return ThirtyTwoBytes_clone(&owner->a);
5583 }
5584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5585         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5586         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5587         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
5588         return ret_arr;
5589 }
5590
5591 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5592         return ChannelMonitor_clone(&owner->b);
5593 }
5594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5595         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5596         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5597         int64_t ret_ref = 0;
5598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5601         ret_ref = (uintptr_t)ret_var.inner;
5602         if (ret_var.is_owned) {
5603                 ret_ref |= 1;
5604         }
5605         return ret_ref;
5606 }
5607
5608 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
5609         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
5610         for (size_t i = 0; i < ret.datalen; i++) {
5611                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
5612         }
5613         return ret;
5614 }
5615 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5616 CHECK(owner->result_ok);
5617         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
5618 }
5619 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5620         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5621         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
5622         int64_tArray ret_arr = NULL;
5623         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5624         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5625         for (size_t j = 0; j < ret_var.datalen; j++) {
5626                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5627                 *ret_conv_35_conv = ret_var.data[j];
5628                 ret_arr_ptr[j] = ((int64_t)ret_conv_35_conv);
5629         }
5630         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5631         FREE(ret_var.data);
5632         return ret_arr;
5633 }
5634
5635 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
5636 CHECK(!owner->result_ok);
5637         return *owner->contents.err;
5638 }
5639 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5640         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
5641         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
5642         return ret_conv;
5643 }
5644
5645 static jclass LDKCOption_u16Z_Some_class = NULL;
5646 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
5647 static jclass LDKCOption_u16Z_None_class = NULL;
5648 static jmethodID LDKCOption_u16Z_None_meth = NULL;
5649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
5650         LDKCOption_u16Z_Some_class =
5651                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
5652         CHECK(LDKCOption_u16Z_Some_class != NULL);
5653         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
5654         CHECK(LDKCOption_u16Z_Some_meth != NULL);
5655         LDKCOption_u16Z_None_class =
5656                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
5657         CHECK(LDKCOption_u16Z_None_class != NULL);
5658         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
5659         CHECK(LDKCOption_u16Z_None_meth != NULL);
5660 }
5661 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5662         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5663         switch(obj->tag) {
5664                 case LDKCOption_u16Z_Some: {
5665                         int16_t some_conv = obj->some;
5666                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
5667                 }
5668                 case LDKCOption_u16Z_None: {
5669                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
5670                 }
5671                 default: abort();
5672         }
5673 }
5674 static jclass LDKAPIError_APIMisuseError_class = NULL;
5675 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
5676 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
5677 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
5678 static jclass LDKAPIError_RouteError_class = NULL;
5679 static jmethodID LDKAPIError_RouteError_meth = NULL;
5680 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
5681 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
5682 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
5683 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
5684 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
5685 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
5686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
5687         LDKAPIError_APIMisuseError_class =
5688                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
5689         CHECK(LDKAPIError_APIMisuseError_class != NULL);
5690         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
5691         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
5692         LDKAPIError_FeeRateTooHigh_class =
5693                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
5694         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
5695         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
5696         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
5697         LDKAPIError_RouteError_class =
5698                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
5699         CHECK(LDKAPIError_RouteError_class != NULL);
5700         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
5701         CHECK(LDKAPIError_RouteError_meth != NULL);
5702         LDKAPIError_ChannelUnavailable_class =
5703                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
5704         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
5705         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
5706         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
5707         LDKAPIError_MonitorUpdateFailed_class =
5708                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
5709         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
5710         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
5711         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
5712         LDKAPIError_IncompatibleShutdownScript_class =
5713                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
5714         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
5715         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
5716         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
5717 }
5718 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5719         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5720         switch(obj->tag) {
5721                 case LDKAPIError_APIMisuseError: {
5722                         LDKStr err_str = obj->api_misuse_error.err;
5723                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5724                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
5725                 }
5726                 case LDKAPIError_FeeRateTooHigh: {
5727                         LDKStr err_str = obj->fee_rate_too_high.err;
5728                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5729                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
5730                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
5731                 }
5732                 case LDKAPIError_RouteError: {
5733                         LDKStr err_str = obj->route_error.err;
5734                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5735                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
5736                 }
5737                 case LDKAPIError_ChannelUnavailable: {
5738                         LDKStr err_str = obj->channel_unavailable.err;
5739                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
5740                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
5741                 }
5742                 case LDKAPIError_MonitorUpdateFailed: {
5743                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
5744                 }
5745                 case LDKAPIError_IncompatibleShutdownScript: {
5746                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
5747                         int64_t script_ref = 0;
5748                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5749                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5750                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
5751                         script_ref = (uintptr_t)script_var.inner & ~1;
5752                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
5753                 }
5754                 default: abort();
5755         }
5756 }
5757 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5758 CHECK(owner->result_ok);
5759         return *owner->contents.result;
5760 }
5761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5762         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5763         CResult_NoneAPIErrorZ_get_ok(owner_conv);
5764 }
5765
5766 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5767 CHECK(!owner->result_ok);
5768         return APIError_clone(&*owner->contents.err);
5769 }
5770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5771         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5772         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5773         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
5774         int64_t ret_ref = (uintptr_t)ret_copy;
5775         return ret_ref;
5776 }
5777
5778 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
5779         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
5780         for (size_t i = 0; i < ret.datalen; i++) {
5781                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
5782         }
5783         return ret;
5784 }
5785 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
5786         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
5787         for (size_t i = 0; i < ret.datalen; i++) {
5788                 ret.data[i] = APIError_clone(&orig->data[i]);
5789         }
5790         return ret;
5791 }
5792 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5793 CHECK(owner->result_ok);
5794         return ThirtyTwoBytes_clone(&*owner->contents.result);
5795 }
5796 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5797         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5798         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5799         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
5800         return ret_arr;
5801 }
5802
5803 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5804 CHECK(!owner->result_ok);
5805         return APIError_clone(&*owner->contents.err);
5806 }
5807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5808         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5809         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5810         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
5811         int64_t ret_ref = (uintptr_t)ret_copy;
5812         return ret_ref;
5813 }
5814
5815 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
5816 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
5817 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
5818 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
5819 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
5820 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
5821 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
5822 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
5823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
5824         LDKPaymentSendFailure_ParameterError_class =
5825                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
5826         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
5827         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
5828         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
5829         LDKPaymentSendFailure_PathParameterError_class =
5830                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
5831         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
5832         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
5833         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
5834         LDKPaymentSendFailure_AllFailedRetrySafe_class =
5835                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
5836         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
5837         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
5838         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
5839         LDKPaymentSendFailure_PartialFailure_class =
5840                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
5841         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
5842         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
5843         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
5844 }
5845 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5846         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5847         switch(obj->tag) {
5848                 case LDKPaymentSendFailure_ParameterError: {
5849                         int64_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
5850                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
5851                 }
5852                 case LDKPaymentSendFailure_PathParameterError: {
5853                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
5854                         int64_tArray path_parameter_error_arr = NULL;
5855                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
5856                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
5857                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
5858                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5859                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
5860                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
5861                                 path_parameter_error_arr_ptr[w] = (int64_t)path_parameter_error_conv_22_conv;
5862                         }
5863                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
5864                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
5865                 }
5866                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
5867                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
5868                         int64_tArray all_failed_retry_safe_arr = NULL;
5869                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
5870                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
5871                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
5872                                 int64_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
5873                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
5874                         }
5875                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
5876                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
5877                 }
5878                 case LDKPaymentSendFailure_PartialFailure: {
5879                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
5880                         int64_tArray results_arr = NULL;
5881                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
5882                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
5883                         for (size_t w = 0; w < results_var.datalen; w++) {
5884                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5885                                 *results_conv_22_conv = results_var.data[w];
5886                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
5887                                 results_arr_ptr[w] = (int64_t)results_conv_22_conv;
5888                         }
5889                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
5890                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
5891                         int64_t failed_paths_retry_ref = 0;
5892                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
5893                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5894                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5895                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
5896                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
5897                         }
5898                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
5899                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
5900                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
5901                 }
5902                 default: abort();
5903         }
5904 }
5905 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5906 CHECK(owner->result_ok);
5907         return ThirtyTwoBytes_clone(&*owner->contents.result);
5908 }
5909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5910         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5911         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
5913         return ret_arr;
5914 }
5915
5916 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5917 CHECK(!owner->result_ok);
5918         return PaymentSendFailure_clone(&*owner->contents.err);
5919 }
5920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5921         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5922         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5923         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
5924         int64_t ret_ref = (uintptr_t)ret_copy;
5925         return ret_ref;
5926 }
5927
5928 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5929 CHECK(owner->result_ok);
5930         return *owner->contents.result;
5931 }
5932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5933         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5934         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
5935 }
5936
5937 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5938 CHECK(!owner->result_ok);
5939         return PaymentSendFailure_clone(&*owner->contents.err);
5940 }
5941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5942         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5943         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5944         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
5945         int64_t ret_ref = (uintptr_t)ret_copy;
5946         return ret_ref;
5947 }
5948
5949 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5950         return ThirtyTwoBytes_clone(&owner->a);
5951 }
5952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5953         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5954         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5955         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
5956         return ret_arr;
5957 }
5958
5959 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5960         return ThirtyTwoBytes_clone(&owner->b);
5961 }
5962 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5963         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5964         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5965         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
5966         return ret_arr;
5967 }
5968
5969 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5970 CHECK(owner->result_ok);
5971         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
5972 }
5973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5974         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5975         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
5976         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
5977         return ((int64_t)ret_conv);
5978 }
5979
5980 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5981 CHECK(!owner->result_ok);
5982         return PaymentSendFailure_clone(&*owner->contents.err);
5983 }
5984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5985         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5986         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5987         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
5988         int64_t ret_ref = (uintptr_t)ret_copy;
5989         return ret_ref;
5990 }
5991
5992 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
5993         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
5994         for (size_t i = 0; i < ret.datalen; i++) {
5995                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
5996         }
5997         return ret;
5998 }
5999 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6000         return ThirtyTwoBytes_clone(&owner->a);
6001 }
6002 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6003         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6004         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6005         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
6006         return ret_arr;
6007 }
6008
6009 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6010         return ThirtyTwoBytes_clone(&owner->b);
6011 }
6012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6013         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6014         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6015         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
6016         return ret_arr;
6017 }
6018
6019 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6020 CHECK(owner->result_ok);
6021         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6022 }
6023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6024         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6025         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6026         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6027         return ((int64_t)ret_conv);
6028 }
6029
6030 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6031 CHECK(!owner->result_ok);
6032         return *owner->contents.err;
6033 }
6034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6035         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6036         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6037 }
6038
6039 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6040 CHECK(owner->result_ok);
6041         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6042 }
6043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6044         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6045         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6046         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6047         return ((int64_t)ret_conv);
6048 }
6049
6050 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6051 CHECK(!owner->result_ok);
6052         return APIError_clone(&*owner->contents.err);
6053 }
6054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6055         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6056         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6057         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6058         int64_t ret_ref = (uintptr_t)ret_copy;
6059         return ret_ref;
6060 }
6061
6062 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6063 CHECK(owner->result_ok);
6064         return ThirtyTwoBytes_clone(&*owner->contents.result);
6065 }
6066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6067         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6068         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6069         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
6070         return ret_arr;
6071 }
6072
6073 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6074 CHECK(!owner->result_ok);
6075         return *owner->contents.err;
6076 }
6077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6078         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6079         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6080 }
6081
6082 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6083 CHECK(owner->result_ok);
6084         return ThirtyTwoBytes_clone(&*owner->contents.result);
6085 }
6086 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6087         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6088         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6089         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
6090         return ret_arr;
6091 }
6092
6093 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6094 CHECK(!owner->result_ok);
6095         return APIError_clone(&*owner->contents.err);
6096 }
6097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6098         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6099         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6100         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6101         int64_t ret_ref = (uintptr_t)ret_copy;
6102         return ret_ref;
6103 }
6104
6105 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6106 CHECK(owner->result_ok);
6107         return ThirtyTwoBytes_clone(&*owner->contents.result);
6108 }
6109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6110         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6111         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6112         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
6113         return ret_arr;
6114 }
6115
6116 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6117 CHECK(!owner->result_ok);
6118         return APIError_clone(&*owner->contents.err);
6119 }
6120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6121         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6122         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6123         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6124         int64_t ret_ref = (uintptr_t)ret_copy;
6125         return ret_ref;
6126 }
6127
6128 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6129 CHECK(owner->result_ok);
6130         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
6131 }
6132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6133         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6134         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
6135         int64_t ret_ref = 0;
6136         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6137         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6139         ret_ref = (uintptr_t)ret_var.inner;
6140         if (ret_var.is_owned) {
6141                 ret_ref |= 1;
6142         }
6143         return ret_ref;
6144 }
6145
6146 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6147 CHECK(!owner->result_ok);
6148         return DecodeError_clone(&*owner->contents.err);
6149 }
6150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6151         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
6152         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
6153         int64_t ret_ref = 0;
6154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6157         ret_ref = (uintptr_t)ret_var.inner;
6158         if (ret_var.is_owned) {
6159                 ret_ref |= 1;
6160         }
6161         return ret_ref;
6162 }
6163
6164 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6165 CHECK(owner->result_ok);
6166         return ChannelCounterparty_clone(&*owner->contents.result);
6167 }
6168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6169         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6170         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
6171         int64_t ret_ref = 0;
6172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6175         ret_ref = (uintptr_t)ret_var.inner;
6176         if (ret_var.is_owned) {
6177                 ret_ref |= 1;
6178         }
6179         return ret_ref;
6180 }
6181
6182 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6183 CHECK(!owner->result_ok);
6184         return DecodeError_clone(&*owner->contents.err);
6185 }
6186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6187         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
6188         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
6189         int64_t ret_ref = 0;
6190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6193         ret_ref = (uintptr_t)ret_var.inner;
6194         if (ret_var.is_owned) {
6195                 ret_ref |= 1;
6196         }
6197         return ret_ref;
6198 }
6199
6200 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6201 CHECK(owner->result_ok);
6202         return ChannelDetails_clone(&*owner->contents.result);
6203 }
6204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6205         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6206         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
6207         int64_t ret_ref = 0;
6208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6211         ret_ref = (uintptr_t)ret_var.inner;
6212         if (ret_var.is_owned) {
6213                 ret_ref |= 1;
6214         }
6215         return ret_ref;
6216 }
6217
6218 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6219 CHECK(!owner->result_ok);
6220         return DecodeError_clone(&*owner->contents.err);
6221 }
6222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6223         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
6224         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
6225         int64_t ret_ref = 0;
6226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6229         ret_ref = (uintptr_t)ret_var.inner;
6230         if (ret_var.is_owned) {
6231                 ret_ref |= 1;
6232         }
6233         return ret_ref;
6234 }
6235
6236 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6237 CHECK(owner->result_ok);
6238         return PhantomRouteHints_clone(&*owner->contents.result);
6239 }
6240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6241         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6242         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
6243         int64_t ret_ref = 0;
6244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6247         ret_ref = (uintptr_t)ret_var.inner;
6248         if (ret_var.is_owned) {
6249                 ret_ref |= 1;
6250         }
6251         return ret_ref;
6252 }
6253
6254 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6255 CHECK(!owner->result_ok);
6256         return DecodeError_clone(&*owner->contents.err);
6257 }
6258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6259         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
6260         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
6261         int64_t ret_ref = 0;
6262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6265         ret_ref = (uintptr_t)ret_var.inner;
6266         if (ret_var.is_owned) {
6267                 ret_ref |= 1;
6268         }
6269         return ret_ref;
6270 }
6271
6272 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6273         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6274         for (size_t i = 0; i < ret.datalen; i++) {
6275                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6276         }
6277         return ret;
6278 }
6279 typedef struct LDKWatch_JCalls {
6280         atomic_size_t refcnt;
6281         JavaVM *vm;
6282         jweak o;
6283         jmethodID watch_channel_meth;
6284         jmethodID update_channel_meth;
6285         jmethodID release_pending_monitor_events_meth;
6286 } LDKWatch_JCalls;
6287 static void LDKWatch_JCalls_free(void* this_arg) {
6288         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6289         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6290                 JNIEnv *env;
6291                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6292                 if (get_jenv_res == JNI_EDETACHED) {
6293                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6294                 } else {
6295                         DO_ASSERT(get_jenv_res == JNI_OK);
6296                 }
6297                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6298                 if (get_jenv_res == JNI_EDETACHED) {
6299                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6300                 }
6301                 FREE(j_calls);
6302         }
6303 }
6304 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6305         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6306         JNIEnv *env;
6307         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6308         if (get_jenv_res == JNI_EDETACHED) {
6309                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6310         } else {
6311                 DO_ASSERT(get_jenv_res == JNI_OK);
6312         }
6313         LDKOutPoint funding_txo_var = funding_txo;
6314         int64_t funding_txo_ref = 0;
6315         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6316         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6317         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6318         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6319         if (funding_txo_var.is_owned) {
6320                 funding_txo_ref |= 1;
6321         }
6322         LDKChannelMonitor monitor_var = monitor;
6323         int64_t monitor_ref = 0;
6324         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6325         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6326         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6327         monitor_ref = (uintptr_t)monitor_var.inner;
6328         if (monitor_var.is_owned) {
6329                 monitor_ref |= 1;
6330         }
6331         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6332         CHECK(obj != NULL);
6333         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
6334         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6335                 (*env)->ExceptionDescribe(env);
6336                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
6337         }
6338         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6339         CHECK_ACCESS(ret_ptr);
6340         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6341         FREE((void*)ret);
6342         if (get_jenv_res == JNI_EDETACHED) {
6343                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6344         }
6345         return ret_conv;
6346 }
6347 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6348         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6349         JNIEnv *env;
6350         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6351         if (get_jenv_res == JNI_EDETACHED) {
6352                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6353         } else {
6354                 DO_ASSERT(get_jenv_res == JNI_OK);
6355         }
6356         LDKOutPoint funding_txo_var = funding_txo;
6357         int64_t funding_txo_ref = 0;
6358         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6359         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6360         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6361         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6362         if (funding_txo_var.is_owned) {
6363                 funding_txo_ref |= 1;
6364         }
6365         LDKChannelMonitorUpdate update_var = update;
6366         int64_t update_ref = 0;
6367         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6368         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6369         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6370         update_ref = (uintptr_t)update_var.inner;
6371         if (update_var.is_owned) {
6372                 update_ref |= 1;
6373         }
6374         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6375         CHECK(obj != NULL);
6376         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
6377         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6378                 (*env)->ExceptionDescribe(env);
6379                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
6380         }
6381         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6382         CHECK_ACCESS(ret_ptr);
6383         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6384         FREE((void*)ret);
6385         if (get_jenv_res == JNI_EDETACHED) {
6386                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6387         }
6388         return ret_conv;
6389 }
6390 LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6391         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6392         JNIEnv *env;
6393         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6394         if (get_jenv_res == JNI_EDETACHED) {
6395                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6396         } else {
6397                 DO_ASSERT(get_jenv_res == JNI_OK);
6398         }
6399         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6400         CHECK(obj != NULL);
6401         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
6402         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6403                 (*env)->ExceptionDescribe(env);
6404                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
6405         }
6406         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_constr;
6407         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6408         if (ret_constr.datalen > 0)
6409                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
6410         else
6411                 ret_constr.data = NULL;
6412         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6413         for (size_t m = 0; m < ret_constr.datalen; m++) {
6414                 int64_t ret_conv_38 = ret_vals[m];
6415                 void* ret_conv_38_ptr = (void*)(((uintptr_t)ret_conv_38) & ~1);
6416                 CHECK_ACCESS(ret_conv_38_ptr);
6417                 LDKC2Tuple_OutPointCVec_MonitorEventZZ ret_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(ret_conv_38_ptr);
6418                 FREE((void*)ret_conv_38);
6419                 ret_constr.data[m] = ret_conv_38_conv;
6420         }
6421         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6422         if (get_jenv_res == JNI_EDETACHED) {
6423                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6424         }
6425         return ret_constr;
6426 }
6427 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6428         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6429         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6430 }
6431 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
6432         jclass c = (*env)->GetObjectClass(env, o);
6433         CHECK(c != NULL);
6434         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6435         atomic_init(&calls->refcnt, 1);
6436         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6437         calls->o = (*env)->NewWeakGlobalRef(env, o);
6438         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
6439         CHECK(calls->watch_channel_meth != NULL);
6440         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
6441         CHECK(calls->update_channel_meth != NULL);
6442         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
6443         CHECK(calls->release_pending_monitor_events_meth != NULL);
6444
6445         LDKWatch ret = {
6446                 .this_arg = (void*) calls,
6447                 .watch_channel = watch_channel_LDKWatch_jcall,
6448                 .update_channel = update_channel_LDKWatch_jcall,
6449                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6450                 .free = LDKWatch_JCalls_free,
6451         };
6452         return ret;
6453 }
6454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
6455         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6456         *res_ptr = LDKWatch_init(env, clz, o);
6457         return (uint64_t)res_ptr;
6458 }
6459 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) {
6460         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6461         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6462         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6463         LDKOutPoint funding_txo_conv;
6464         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6465         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6466         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6467         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6468         LDKChannelMonitor monitor_conv;
6469         monitor_conv.inner = (void*)(monitor & (~1));
6470         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
6471         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6472         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6473         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6474         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
6475         return (int64_t)ret_conv;
6476 }
6477
6478 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) {
6479         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6480         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6481         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6482         LDKOutPoint funding_txo_conv;
6483         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6484         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6485         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6486         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6487         LDKChannelMonitorUpdate update_conv;
6488         update_conv.inner = (void*)(update & (~1));
6489         update_conv.is_owned = (update & 1) || (update == 0);
6490         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6491         update_conv = ChannelMonitorUpdate_clone(&update_conv);
6492         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6493         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
6494         return (int64_t)ret_conv;
6495 }
6496
6497 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6498         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6499         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6500         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6501         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6502         int64_tArray ret_arr = NULL;
6503         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6504         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6505         for (size_t m = 0; m < ret_var.datalen; m++) {
6506                 LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv_38_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
6507                 *ret_conv_38_conv = ret_var.data[m];
6508                 ret_arr_ptr[m] = ((int64_t)ret_conv_38_conv);
6509         }
6510         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6511         FREE(ret_var.data);
6512         return ret_arr;
6513 }
6514
6515 typedef struct LDKBroadcasterInterface_JCalls {
6516         atomic_size_t refcnt;
6517         JavaVM *vm;
6518         jweak o;
6519         jmethodID broadcast_transaction_meth;
6520 } LDKBroadcasterInterface_JCalls;
6521 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6522         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6523         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6524                 JNIEnv *env;
6525                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6526                 if (get_jenv_res == JNI_EDETACHED) {
6527                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6528                 } else {
6529                         DO_ASSERT(get_jenv_res == JNI_OK);
6530                 }
6531                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6532                 if (get_jenv_res == JNI_EDETACHED) {
6533                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6534                 }
6535                 FREE(j_calls);
6536         }
6537 }
6538 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
6539         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6540         JNIEnv *env;
6541         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6542         if (get_jenv_res == JNI_EDETACHED) {
6543                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6544         } else {
6545                 DO_ASSERT(get_jenv_res == JNI_OK);
6546         }
6547         LDKTransaction tx_var = tx;
6548         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
6549         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
6550         Transaction_free(tx_var);
6551         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6552         CHECK(obj != NULL);
6553         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
6554         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6555                 (*env)->ExceptionDescribe(env);
6556                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
6557         }
6558         if (get_jenv_res == JNI_EDETACHED) {
6559                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6560         }
6561 }
6562 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6563         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6564         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6565 }
6566 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
6567         jclass c = (*env)->GetObjectClass(env, o);
6568         CHECK(c != NULL);
6569         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6570         atomic_init(&calls->refcnt, 1);
6571         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6572         calls->o = (*env)->NewWeakGlobalRef(env, o);
6573         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
6574         CHECK(calls->broadcast_transaction_meth != NULL);
6575
6576         LDKBroadcasterInterface ret = {
6577                 .this_arg = (void*) calls,
6578                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
6579                 .free = LDKBroadcasterInterface_JCalls_free,
6580         };
6581         return ret;
6582 }
6583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6584         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6585         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
6586         return (uint64_t)res_ptr;
6587 }
6588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
6589         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6590         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6591         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6592         LDKTransaction tx_ref;
6593         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
6594         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
6595         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
6596         tx_ref.data_is_owned = true;
6597         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
6598 }
6599
6600 typedef struct LDKKeysInterface_JCalls {
6601         atomic_size_t refcnt;
6602         JavaVM *vm;
6603         jweak o;
6604         jmethodID get_node_secret_meth;
6605         jmethodID get_destination_script_meth;
6606         jmethodID get_shutdown_scriptpubkey_meth;
6607         jmethodID get_channel_signer_meth;
6608         jmethodID get_secure_random_bytes_meth;
6609         jmethodID read_chan_signer_meth;
6610         jmethodID sign_invoice_meth;
6611         jmethodID get_inbound_payment_key_material_meth;
6612 } LDKKeysInterface_JCalls;
6613 static void LDKKeysInterface_JCalls_free(void* this_arg) {
6614         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6615         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6616                 JNIEnv *env;
6617                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6618                 if (get_jenv_res == JNI_EDETACHED) {
6619                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6620                 } else {
6621                         DO_ASSERT(get_jenv_res == JNI_OK);
6622                 }
6623                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6624                 if (get_jenv_res == JNI_EDETACHED) {
6625                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6626                 }
6627                 FREE(j_calls);
6628         }
6629 }
6630 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
6631         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6632         JNIEnv *env;
6633         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6634         if (get_jenv_res == JNI_EDETACHED) {
6635                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6636         } else {
6637                 DO_ASSERT(get_jenv_res == JNI_OK);
6638         }
6639         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
6640         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6641         CHECK(obj != NULL);
6642         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
6643         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6644                 (*env)->ExceptionDescribe(env);
6645                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
6646         }
6647         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6648         CHECK_ACCESS(ret_ptr);
6649         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
6650         FREE((void*)ret);
6651         if (get_jenv_res == JNI_EDETACHED) {
6652                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6653         }
6654         return ret_conv;
6655 }
6656 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
6657         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6658         JNIEnv *env;
6659         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6660         if (get_jenv_res == JNI_EDETACHED) {
6661                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6662         } else {
6663                 DO_ASSERT(get_jenv_res == JNI_OK);
6664         }
6665         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6666         CHECK(obj != NULL);
6667         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
6668         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6669                 (*env)->ExceptionDescribe(env);
6670                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
6671         }
6672         LDKCVec_u8Z ret_ref;
6673         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6674         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6675         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6676         if (get_jenv_res == JNI_EDETACHED) {
6677                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6678         }
6679         return ret_ref;
6680 }
6681 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
6682         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6683         JNIEnv *env;
6684         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6685         if (get_jenv_res == JNI_EDETACHED) {
6686                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6687         } else {
6688                 DO_ASSERT(get_jenv_res == JNI_OK);
6689         }
6690         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6691         CHECK(obj != NULL);
6692         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
6693         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6694                 (*env)->ExceptionDescribe(env);
6695                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
6696         }
6697         LDKShutdownScript ret_conv;
6698         ret_conv.inner = (void*)(ret & (~1));
6699         ret_conv.is_owned = (ret & 1) || (ret == 0);
6700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
6701         if (get_jenv_res == JNI_EDETACHED) {
6702                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6703         }
6704         return ret_conv;
6705 }
6706 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
6707         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6708         JNIEnv *env;
6709         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6710         if (get_jenv_res == JNI_EDETACHED) {
6711                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6712         } else {
6713                 DO_ASSERT(get_jenv_res == JNI_OK);
6714         }
6715         jboolean inbound_conv = inbound;
6716         int64_t channel_value_satoshis_conv = channel_value_satoshis;
6717         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6718         CHECK(obj != NULL);
6719         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
6720         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6721                 (*env)->ExceptionDescribe(env);
6722                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
6723         }
6724         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6725         CHECK_ACCESS(ret_ptr);
6726         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
6727         FREE((void*)ret);
6728         if (get_jenv_res == JNI_EDETACHED) {
6729                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6730         }
6731         return ret_conv;
6732 }
6733 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
6734         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6735         JNIEnv *env;
6736         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6737         if (get_jenv_res == JNI_EDETACHED) {
6738                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6739         } else {
6740                 DO_ASSERT(get_jenv_res == JNI_OK);
6741         }
6742         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6743         CHECK(obj != NULL);
6744         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
6745         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6746                 (*env)->ExceptionDescribe(env);
6747                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
6748         }
6749         LDKThirtyTwoBytes ret_ref;
6750         CHECK((*env)->GetArrayLength(env, ret) == 32);
6751         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6752         if (get_jenv_res == JNI_EDETACHED) {
6753                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6754         }
6755         return ret_ref;
6756 }
6757 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
6758         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6759         JNIEnv *env;
6760         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6761         if (get_jenv_res == JNI_EDETACHED) {
6762                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6763         } else {
6764                 DO_ASSERT(get_jenv_res == JNI_OK);
6765         }
6766         LDKu8slice reader_var = reader;
6767         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
6768         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
6769         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6770         CHECK(obj != NULL);
6771         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
6772         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6773                 (*env)->ExceptionDescribe(env);
6774                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
6775         }
6776         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6777         CHECK_ACCESS(ret_ptr);
6778         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
6779         FREE((void*)ret);
6780         if (get_jenv_res == JNI_EDETACHED) {
6781                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6782         }
6783         return ret_conv;
6784 }
6785 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
6786         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6787         JNIEnv *env;
6788         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6789         if (get_jenv_res == JNI_EDETACHED) {
6790                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6791         } else {
6792                 DO_ASSERT(get_jenv_res == JNI_OK);
6793         }
6794         LDKu8slice hrp_bytes_var = hrp_bytes;
6795         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
6796         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
6797         LDKCVec_u5Z invoice_data_var = invoice_data;
6798         jobjectArray invoice_data_arr = NULL;
6799         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
6800         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
6801         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
6802                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
6803                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
6804         }
6805         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
6806         FREE(invoice_data_var.data);
6807         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
6808         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6809         CHECK(obj != NULL);
6810         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
6811         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6812                 (*env)->ExceptionDescribe(env);
6813                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
6814         }
6815         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6816         CHECK_ACCESS(ret_ptr);
6817         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6818         FREE((void*)ret);
6819         if (get_jenv_res == JNI_EDETACHED) {
6820                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6821         }
6822         return ret_conv;
6823 }
6824 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
6825         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6826         JNIEnv *env;
6827         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6828         if (get_jenv_res == JNI_EDETACHED) {
6829                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6830         } else {
6831                 DO_ASSERT(get_jenv_res == JNI_OK);
6832         }
6833         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6834         CHECK(obj != NULL);
6835         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
6836         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6837                 (*env)->ExceptionDescribe(env);
6838                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
6839         }
6840         LDKThirtyTwoBytes ret_ref;
6841         CHECK((*env)->GetArrayLength(env, ret) == 32);
6842         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6843         if (get_jenv_res == JNI_EDETACHED) {
6844                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6845         }
6846         return ret_ref;
6847 }
6848 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
6849         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
6850         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6851 }
6852 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
6853         jclass c = (*env)->GetObjectClass(env, o);
6854         CHECK(c != NULL);
6855         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
6856         atomic_init(&calls->refcnt, 1);
6857         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6858         calls->o = (*env)->NewWeakGlobalRef(env, o);
6859         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
6860         CHECK(calls->get_node_secret_meth != NULL);
6861         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
6862         CHECK(calls->get_destination_script_meth != NULL);
6863         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
6864         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
6865         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
6866         CHECK(calls->get_channel_signer_meth != NULL);
6867         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
6868         CHECK(calls->get_secure_random_bytes_meth != NULL);
6869         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
6870         CHECK(calls->read_chan_signer_meth != NULL);
6871         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
6872         CHECK(calls->sign_invoice_meth != NULL);
6873         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
6874         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
6875
6876         LDKKeysInterface ret = {
6877                 .this_arg = (void*) calls,
6878                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
6879                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
6880                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
6881                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
6882                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
6883                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
6884                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
6885                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
6886                 .free = LDKKeysInterface_JCalls_free,
6887         };
6888         return ret;
6889 }
6890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6891         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6892         *res_ptr = LDKKeysInterface_init(env, clz, o);
6893         return (uint64_t)res_ptr;
6894 }
6895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
6896         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6897         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6898         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6899         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
6900         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
6901         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
6902         return (int64_t)ret_conv;
6903 }
6904
6905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
6906         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6907         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6908         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6909         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6910         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6911         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6912         CVec_u8Z_free(ret_var);
6913         return ret_arr;
6914 }
6915
6916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
6917         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6918         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6919         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6920         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6921         int64_t ret_ref = 0;
6922         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6923         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6925         ret_ref = (uintptr_t)ret_var.inner;
6926         if (ret_var.is_owned) {
6927                 ret_ref |= 1;
6928         }
6929         return ret_ref;
6930 }
6931
6932 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) {
6933         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6934         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6935         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6936         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6937         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6938         return (int64_t)ret_ret;
6939 }
6940
6941 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
6942         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6943         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6944         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6945         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6946         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
6947         return ret_arr;
6948 }
6949
6950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
6951         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6952         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6953         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6954         LDKu8slice reader_ref;
6955         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
6956         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
6957         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6958         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6959         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
6960         return (int64_t)ret_conv;
6961 }
6962
6963 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) {
6964         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6965         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6966         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6967         LDKu8slice hrp_bytes_ref;
6968         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
6969         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
6970         LDKCVec_u5Z invoice_data_constr;
6971         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
6972         if (invoice_data_constr.datalen > 0)
6973                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
6974         else
6975                 invoice_data_constr.data = NULL;
6976         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
6977         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
6978                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
6979                 
6980                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
6981         }
6982         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
6983         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
6984         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6985         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
6986         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
6987         return (int64_t)ret_conv;
6988 }
6989
6990 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
6991         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6992         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6993         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6994         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6995         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
6996         return ret_arr;
6997 }
6998
6999 typedef struct LDKFeeEstimator_JCalls {
7000         atomic_size_t refcnt;
7001         JavaVM *vm;
7002         jweak o;
7003         jmethodID get_est_sat_per_1000_weight_meth;
7004 } LDKFeeEstimator_JCalls;
7005 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
7006         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7007         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7008                 JNIEnv *env;
7009                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7010                 if (get_jenv_res == JNI_EDETACHED) {
7011                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7012                 } else {
7013                         DO_ASSERT(get_jenv_res == JNI_OK);
7014                 }
7015                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7016                 if (get_jenv_res == JNI_EDETACHED) {
7017                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7018                 }
7019                 FREE(j_calls);
7020         }
7021 }
7022 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
7023         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7024         JNIEnv *env;
7025         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7026         if (get_jenv_res == JNI_EDETACHED) {
7027                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7028         } else {
7029                 DO_ASSERT(get_jenv_res == JNI_OK);
7030         }
7031         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
7032         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7033         CHECK(obj != NULL);
7034         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
7035         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7036                 (*env)->ExceptionDescribe(env);
7037                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
7038         }
7039         if (get_jenv_res == JNI_EDETACHED) {
7040                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7041         }
7042         return ret;
7043 }
7044 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
7045         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
7046         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7047 }
7048 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
7049         jclass c = (*env)->GetObjectClass(env, o);
7050         CHECK(c != NULL);
7051         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
7052         atomic_init(&calls->refcnt, 1);
7053         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7054         calls->o = (*env)->NewWeakGlobalRef(env, o);
7055         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
7056         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
7057
7058         LDKFeeEstimator ret = {
7059                 .this_arg = (void*) calls,
7060                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
7061                 .free = LDKFeeEstimator_JCalls_free,
7062         };
7063         return ret;
7064 }
7065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
7066         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
7067         *res_ptr = LDKFeeEstimator_init(env, clz, o);
7068         return (uint64_t)res_ptr;
7069 }
7070 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) {
7071         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7072         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7073         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
7074         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
7075         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
7076         return ret_conv;
7077 }
7078
7079 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7080         return ThirtyTwoBytes_clone(&owner->a);
7081 }
7082 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7083         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
7084         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7085         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
7086         return ret_arr;
7087 }
7088
7089 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7090         return &owner->b;
7091 }
7092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7093         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
7094         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
7095         int64_t ret_ref = 0;
7096         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7097         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7099         ret_ref = (uintptr_t)ret_var.inner & ~1;
7100         return ret_ref;
7101 }
7102
7103 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7104 CHECK(owner->result_ok);
7105         return &*owner->contents.result;
7106 }
7107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7108         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7109         int64_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
7110         return ret_ret;
7111 }
7112
7113 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7114 CHECK(!owner->result_ok);
7115         return DecodeError_clone(&*owner->contents.err);
7116 }
7117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7118         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
7119         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
7120         int64_t ret_ref = 0;
7121         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7122         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7124         ret_ref = (uintptr_t)ret_var.inner;
7125         if (ret_var.is_owned) {
7126                 ret_ref |= 1;
7127         }
7128         return ret_ref;
7129 }
7130
7131 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7132 CHECK(owner->result_ok);
7133         return ChannelConfig_clone(&*owner->contents.result);
7134 }
7135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7136         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7137         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
7138         int64_t ret_ref = 0;
7139         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7140         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7142         ret_ref = (uintptr_t)ret_var.inner;
7143         if (ret_var.is_owned) {
7144                 ret_ref |= 1;
7145         }
7146         return ret_ref;
7147 }
7148
7149 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7150 CHECK(!owner->result_ok);
7151         return DecodeError_clone(&*owner->contents.err);
7152 }
7153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7154         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
7155         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
7156         int64_t ret_ref = 0;
7157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7160         ret_ref = (uintptr_t)ret_var.inner;
7161         if (ret_var.is_owned) {
7162                 ret_ref |= 1;
7163         }
7164         return ret_ref;
7165 }
7166
7167 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7168 CHECK(owner->result_ok);
7169         return OutPoint_clone(&*owner->contents.result);
7170 }
7171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7172         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7173         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
7174         int64_t ret_ref = 0;
7175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7178         ret_ref = (uintptr_t)ret_var.inner;
7179         if (ret_var.is_owned) {
7180                 ret_ref |= 1;
7181         }
7182         return ret_ref;
7183 }
7184
7185 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7186 CHECK(!owner->result_ok);
7187         return DecodeError_clone(&*owner->contents.err);
7188 }
7189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7190         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
7191         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
7192         int64_t ret_ref = 0;
7193         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7194         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7196         ret_ref = (uintptr_t)ret_var.inner;
7197         if (ret_var.is_owned) {
7198                 ret_ref |= 1;
7199         }
7200         return ret_ref;
7201 }
7202
7203 typedef struct LDKType_JCalls {
7204         atomic_size_t refcnt;
7205         JavaVM *vm;
7206         jweak o;
7207         jmethodID type_id_meth;
7208         jmethodID debug_str_meth;
7209         jmethodID write_meth;
7210 } LDKType_JCalls;
7211 static void LDKType_JCalls_free(void* this_arg) {
7212         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7213         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7214                 JNIEnv *env;
7215                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7216                 if (get_jenv_res == JNI_EDETACHED) {
7217                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7218                 } else {
7219                         DO_ASSERT(get_jenv_res == JNI_OK);
7220                 }
7221                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7222                 if (get_jenv_res == JNI_EDETACHED) {
7223                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7224                 }
7225                 FREE(j_calls);
7226         }
7227 }
7228 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7229         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7230         JNIEnv *env;
7231         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7232         if (get_jenv_res == JNI_EDETACHED) {
7233                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7234         } else {
7235                 DO_ASSERT(get_jenv_res == JNI_OK);
7236         }
7237         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7238         CHECK(obj != NULL);
7239         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
7240         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7241                 (*env)->ExceptionDescribe(env);
7242                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
7243         }
7244         if (get_jenv_res == JNI_EDETACHED) {
7245                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7246         }
7247         return ret;
7248 }
7249 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
7250         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7251         JNIEnv *env;
7252         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7253         if (get_jenv_res == JNI_EDETACHED) {
7254                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7255         } else {
7256                 DO_ASSERT(get_jenv_res == JNI_OK);
7257         }
7258         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7259         CHECK(obj != NULL);
7260         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
7261         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7262                 (*env)->ExceptionDescribe(env);
7263                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
7264         }
7265         LDKStr ret_conv = java_to_owned_str(env, ret);
7266         if (get_jenv_res == JNI_EDETACHED) {
7267                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7268         }
7269         return ret_conv;
7270 }
7271 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
7272         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7273         JNIEnv *env;
7274         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7275         if (get_jenv_res == JNI_EDETACHED) {
7276                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7277         } else {
7278                 DO_ASSERT(get_jenv_res == JNI_OK);
7279         }
7280         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7281         CHECK(obj != NULL);
7282         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
7283         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7284                 (*env)->ExceptionDescribe(env);
7285                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
7286         }
7287         LDKCVec_u8Z ret_ref;
7288         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7289         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7290         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7291         if (get_jenv_res == JNI_EDETACHED) {
7292                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7293         }
7294         return ret_ref;
7295 }
7296 static void LDKType_JCalls_cloned(LDKType* new_obj) {
7297         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
7298         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7299 }
7300 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
7301         jclass c = (*env)->GetObjectClass(env, o);
7302         CHECK(c != NULL);
7303         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
7304         atomic_init(&calls->refcnt, 1);
7305         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7306         calls->o = (*env)->NewWeakGlobalRef(env, o);
7307         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
7308         CHECK(calls->type_id_meth != NULL);
7309         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
7310         CHECK(calls->debug_str_meth != NULL);
7311         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
7312         CHECK(calls->write_meth != NULL);
7313
7314         LDKType ret = {
7315                 .this_arg = (void*) calls,
7316                 .type_id = type_id_LDKType_jcall,
7317                 .debug_str = debug_str_LDKType_jcall,
7318                 .write = write_LDKType_jcall,
7319                 .cloned = LDKType_JCalls_cloned,
7320                 .free = LDKType_JCalls_free,
7321         };
7322         return ret;
7323 }
7324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
7325         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
7326         *res_ptr = LDKType_init(env, clz, o);
7327         return (uint64_t)res_ptr;
7328 }
7329 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
7330         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7331         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7332         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7333         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
7334         return ret_conv;
7335 }
7336
7337 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
7338         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7339         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7340         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7341         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
7342         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7343         Str_free(ret_str);
7344         return ret_conv;
7345 }
7346
7347 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
7348         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7349         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7350         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7351         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7352         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7353         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7354         CVec_u8Z_free(ret_var);
7355         return ret_arr;
7356 }
7357
7358 static jclass LDKCOption_TypeZ_Some_class = NULL;
7359 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
7360 static jclass LDKCOption_TypeZ_None_class = NULL;
7361 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
7362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
7363         LDKCOption_TypeZ_Some_class =
7364                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
7365         CHECK(LDKCOption_TypeZ_Some_class != NULL);
7366         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
7367         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
7368         LDKCOption_TypeZ_None_class =
7369                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
7370         CHECK(LDKCOption_TypeZ_None_class != NULL);
7371         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
7372         CHECK(LDKCOption_TypeZ_None_meth != NULL);
7373 }
7374 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7375         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
7376         switch(obj->tag) {
7377                 case LDKCOption_TypeZ_Some: {
7378                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
7379                         *some_ret = Type_clone(&obj->some);
7380                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (int64_t)some_ret);
7381                 }
7382                 case LDKCOption_TypeZ_None: {
7383                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
7384                 }
7385                 default: abort();
7386         }
7387 }
7388 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7389 CHECK(owner->result_ok);
7390         return COption_TypeZ_clone(&*owner->contents.result);
7391 }
7392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7393         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7394         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
7395         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7396         int64_t ret_ref = (uintptr_t)ret_copy;
7397         return ret_ref;
7398 }
7399
7400 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7401 CHECK(!owner->result_ok);
7402         return DecodeError_clone(&*owner->contents.err);
7403 }
7404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7405         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
7406         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7407         int64_t ret_ref = 0;
7408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7411         ret_ref = (uintptr_t)ret_var.inner;
7412         if (ret_var.is_owned) {
7413                 ret_ref |= 1;
7414         }
7415         return ret_ref;
7416 }
7417
7418 static jclass LDKPaymentError_Invoice_class = NULL;
7419 static jmethodID LDKPaymentError_Invoice_meth = NULL;
7420 static jclass LDKPaymentError_Routing_class = NULL;
7421 static jmethodID LDKPaymentError_Routing_meth = NULL;
7422 static jclass LDKPaymentError_Sending_class = NULL;
7423 static jmethodID LDKPaymentError_Sending_meth = NULL;
7424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
7425         LDKPaymentError_Invoice_class =
7426                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
7427         CHECK(LDKPaymentError_Invoice_class != NULL);
7428         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
7429         CHECK(LDKPaymentError_Invoice_meth != NULL);
7430         LDKPaymentError_Routing_class =
7431                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
7432         CHECK(LDKPaymentError_Routing_class != NULL);
7433         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
7434         CHECK(LDKPaymentError_Routing_meth != NULL);
7435         LDKPaymentError_Sending_class =
7436                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
7437         CHECK(LDKPaymentError_Sending_class != NULL);
7438         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
7439         CHECK(LDKPaymentError_Sending_meth != NULL);
7440 }
7441 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7442         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
7443         switch(obj->tag) {
7444                 case LDKPaymentError_Invoice: {
7445                         LDKStr invoice_str = obj->invoice;
7446                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
7447                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
7448                 }
7449                 case LDKPaymentError_Routing: {
7450                         LDKLightningError routing_var = obj->routing;
7451                         int64_t routing_ref = 0;
7452                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7453                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7454                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
7455                         routing_ref = (uintptr_t)routing_var.inner & ~1;
7456                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
7457                 }
7458                 case LDKPaymentError_Sending: {
7459                         int64_t sending_ref = ((uintptr_t)&obj->sending) | 1;
7460                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
7461                 }
7462                 default: abort();
7463         }
7464 }
7465 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7466 CHECK(owner->result_ok);
7467         return ThirtyTwoBytes_clone(&*owner->contents.result);
7468 }
7469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7470         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7471         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
7473         return ret_arr;
7474 }
7475
7476 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7477 CHECK(!owner->result_ok);
7478         return PaymentError_clone(&*owner->contents.err);
7479 }
7480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7481         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
7482         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
7483         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
7484         int64_t ret_ref = (uintptr_t)ret_copy;
7485         return ret_ref;
7486 }
7487
7488 static jclass LDKParseError_Bech32Error_class = NULL;
7489 static jmethodID LDKParseError_Bech32Error_meth = NULL;
7490 static jclass LDKParseError_ParseAmountError_class = NULL;
7491 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
7492 static jclass LDKParseError_MalformedSignature_class = NULL;
7493 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
7494 static jclass LDKParseError_BadPrefix_class = NULL;
7495 static jmethodID LDKParseError_BadPrefix_meth = NULL;
7496 static jclass LDKParseError_UnknownCurrency_class = NULL;
7497 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
7498 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
7499 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
7500 static jclass LDKParseError_MalformedHRP_class = NULL;
7501 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
7502 static jclass LDKParseError_TooShortDataPart_class = NULL;
7503 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
7504 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
7505 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
7506 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
7507 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
7508 static jclass LDKParseError_PaddingError_class = NULL;
7509 static jmethodID LDKParseError_PaddingError_meth = NULL;
7510 static jclass LDKParseError_IntegerOverflowError_class = NULL;
7511 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
7512 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
7513 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
7514 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
7515 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
7516 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
7517 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
7518 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
7519 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
7520 static jclass LDKParseError_InvalidSliceLength_class = NULL;
7521 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
7522 static jclass LDKParseError_Skip_class = NULL;
7523 static jmethodID LDKParseError_Skip_meth = NULL;
7524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
7525         LDKParseError_Bech32Error_class =
7526                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
7527         CHECK(LDKParseError_Bech32Error_class != NULL);
7528         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
7529         CHECK(LDKParseError_Bech32Error_meth != NULL);
7530         LDKParseError_ParseAmountError_class =
7531                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
7532         CHECK(LDKParseError_ParseAmountError_class != NULL);
7533         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
7534         CHECK(LDKParseError_ParseAmountError_meth != NULL);
7535         LDKParseError_MalformedSignature_class =
7536                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
7537         CHECK(LDKParseError_MalformedSignature_class != NULL);
7538         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
7539         CHECK(LDKParseError_MalformedSignature_meth != NULL);
7540         LDKParseError_BadPrefix_class =
7541                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
7542         CHECK(LDKParseError_BadPrefix_class != NULL);
7543         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
7544         CHECK(LDKParseError_BadPrefix_meth != NULL);
7545         LDKParseError_UnknownCurrency_class =
7546                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
7547         CHECK(LDKParseError_UnknownCurrency_class != NULL);
7548         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
7549         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
7550         LDKParseError_UnknownSiPrefix_class =
7551                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
7552         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
7553         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
7554         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
7555         LDKParseError_MalformedHRP_class =
7556                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
7557         CHECK(LDKParseError_MalformedHRP_class != NULL);
7558         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
7559         CHECK(LDKParseError_MalformedHRP_meth != NULL);
7560         LDKParseError_TooShortDataPart_class =
7561                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
7562         CHECK(LDKParseError_TooShortDataPart_class != NULL);
7563         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
7564         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
7565         LDKParseError_UnexpectedEndOfTaggedFields_class =
7566                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
7567         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
7568         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
7569         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
7570         LDKParseError_DescriptionDecodeError_class =
7571                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
7572         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
7573         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
7574         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
7575         LDKParseError_PaddingError_class =
7576                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
7577         CHECK(LDKParseError_PaddingError_class != NULL);
7578         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
7579         CHECK(LDKParseError_PaddingError_meth != NULL);
7580         LDKParseError_IntegerOverflowError_class =
7581                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
7582         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
7583         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
7584         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
7585         LDKParseError_InvalidSegWitProgramLength_class =
7586                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
7587         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
7588         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
7589         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
7590         LDKParseError_InvalidPubKeyHashLength_class =
7591                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
7592         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
7593         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
7594         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
7595         LDKParseError_InvalidScriptHashLength_class =
7596                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
7597         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
7598         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
7599         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
7600         LDKParseError_InvalidRecoveryId_class =
7601                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
7602         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
7603         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
7604         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
7605         LDKParseError_InvalidSliceLength_class =
7606                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
7607         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
7608         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
7609         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
7610         LDKParseError_Skip_class =
7611                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
7612         CHECK(LDKParseError_Skip_class != NULL);
7613         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
7614         CHECK(LDKParseError_Skip_meth != NULL);
7615 }
7616 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7617         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
7618         switch(obj->tag) {
7619                 case LDKParseError_Bech32Error: {
7620                         int64_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
7621                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
7622                 }
7623                 case LDKParseError_ParseAmountError: {
7624                         /*obj->parse_amount_error*/
7625                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
7626                 }
7627                 case LDKParseError_MalformedSignature: {
7628                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
7629                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
7630                 }
7631                 case LDKParseError_BadPrefix: {
7632                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
7633                 }
7634                 case LDKParseError_UnknownCurrency: {
7635                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
7636                 }
7637                 case LDKParseError_UnknownSiPrefix: {
7638                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
7639                 }
7640                 case LDKParseError_MalformedHRP: {
7641                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
7642                 }
7643                 case LDKParseError_TooShortDataPart: {
7644                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
7645                 }
7646                 case LDKParseError_UnexpectedEndOfTaggedFields: {
7647                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
7648                 }
7649                 case LDKParseError_DescriptionDecodeError: {
7650                         /*obj->description_decode_error*/
7651                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
7652                 }
7653                 case LDKParseError_PaddingError: {
7654                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
7655                 }
7656                 case LDKParseError_IntegerOverflowError: {
7657                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
7658                 }
7659                 case LDKParseError_InvalidSegWitProgramLength: {
7660                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
7661                 }
7662                 case LDKParseError_InvalidPubKeyHashLength: {
7663                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
7664                 }
7665                 case LDKParseError_InvalidScriptHashLength: {
7666                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
7667                 }
7668                 case LDKParseError_InvalidRecoveryId: {
7669                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
7670                 }
7671                 case LDKParseError_InvalidSliceLength: {
7672                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
7673                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
7674                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
7675                 }
7676                 case LDKParseError_Skip: {
7677                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
7678                 }
7679                 default: abort();
7680         }
7681 }
7682 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7683 CHECK(owner->result_ok);
7684         return SiPrefix_clone(&*owner->contents.result);
7685 }
7686 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7687         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7688         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
7689         return ret_conv;
7690 }
7691
7692 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
7693 CHECK(!owner->result_ok);
7694         return ParseError_clone(&*owner->contents.err);
7695 }
7696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7697         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
7698         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7699         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
7700         int64_t ret_ref = (uintptr_t)ret_copy;
7701         return ret_ref;
7702 }
7703
7704 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
7705 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
7706 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
7707 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
7708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
7709         LDKParseOrSemanticError_ParseError_class =
7710                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
7711         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
7712         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
7713         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
7714         LDKParseOrSemanticError_SemanticError_class =
7715                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
7716         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
7717         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
7718         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
7719 }
7720 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7721         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
7722         switch(obj->tag) {
7723                 case LDKParseOrSemanticError_ParseError: {
7724                         int64_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
7725                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
7726                 }
7727                 case LDKParseOrSemanticError_SemanticError: {
7728                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
7729                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
7730                 }
7731                 default: abort();
7732         }
7733 }
7734 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7735 CHECK(owner->result_ok);
7736         return Invoice_clone(&*owner->contents.result);
7737 }
7738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7739         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7740         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
7741         int64_t ret_ref = 0;
7742         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7743         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7745         ret_ref = (uintptr_t)ret_var.inner;
7746         if (ret_var.is_owned) {
7747                 ret_ref |= 1;
7748         }
7749         return ret_ref;
7750 }
7751
7752 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7753 CHECK(!owner->result_ok);
7754         return ParseOrSemanticError_clone(&*owner->contents.err);
7755 }
7756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7757         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7758         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
7759         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
7760         int64_t ret_ref = (uintptr_t)ret_copy;
7761         return ret_ref;
7762 }
7763
7764 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7765 CHECK(owner->result_ok);
7766         return SignedRawInvoice_clone(&*owner->contents.result);
7767 }
7768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7769         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7770         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
7771         int64_t ret_ref = 0;
7772         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7773         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7775         ret_ref = (uintptr_t)ret_var.inner;
7776         if (ret_var.is_owned) {
7777                 ret_ref |= 1;
7778         }
7779         return ret_ref;
7780 }
7781
7782 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7783 CHECK(!owner->result_ok);
7784         return ParseError_clone(&*owner->contents.err);
7785 }
7786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7787         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7788         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7789         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
7790         int64_t ret_ref = (uintptr_t)ret_copy;
7791         return ret_ref;
7792 }
7793
7794 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7795         return RawInvoice_clone(&owner->a);
7796 }
7797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7798         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7799         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
7800         int64_t ret_ref = 0;
7801         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7802         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7804         ret_ref = (uintptr_t)ret_var.inner;
7805         if (ret_var.is_owned) {
7806                 ret_ref |= 1;
7807         }
7808         return ret_ref;
7809 }
7810
7811 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7812         return ThirtyTwoBytes_clone(&owner->b);
7813 }
7814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7815         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7816         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7817         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
7818         return ret_arr;
7819 }
7820
7821 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7822         return InvoiceSignature_clone(&owner->c);
7823 }
7824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7825         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7826         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
7827         int64_t ret_ref = 0;
7828         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7829         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7831         ret_ref = (uintptr_t)ret_var.inner;
7832         if (ret_var.is_owned) {
7833                 ret_ref |= 1;
7834         }
7835         return ret_ref;
7836 }
7837
7838 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7839 CHECK(owner->result_ok);
7840         return PayeePubKey_clone(&*owner->contents.result);
7841 }
7842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7843         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7844         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
7845         int64_t ret_ref = 0;
7846         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7847         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7849         ret_ref = (uintptr_t)ret_var.inner;
7850         if (ret_var.is_owned) {
7851                 ret_ref |= 1;
7852         }
7853         return ret_ref;
7854 }
7855
7856 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7857 CHECK(!owner->result_ok);
7858         return *owner->contents.err;
7859 }
7860 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7861         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7862         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
7863         return ret_conv;
7864 }
7865
7866 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
7867         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
7868         for (size_t i = 0; i < ret.datalen; i++) {
7869                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
7870         }
7871         return ret;
7872 }
7873 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7874 CHECK(owner->result_ok);
7875         return PositiveTimestamp_clone(&*owner->contents.result);
7876 }
7877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7878         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7879         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
7880         int64_t ret_ref = 0;
7881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7884         ret_ref = (uintptr_t)ret_var.inner;
7885         if (ret_var.is_owned) {
7886                 ret_ref |= 1;
7887         }
7888         return ret_ref;
7889 }
7890
7891 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7892 CHECK(!owner->result_ok);
7893         return CreationError_clone(&*owner->contents.err);
7894 }
7895 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7896         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7897         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
7898         return ret_conv;
7899 }
7900
7901 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7902 CHECK(owner->result_ok);
7903         return *owner->contents.result;
7904 }
7905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7906         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7907         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
7908 }
7909
7910 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7911 CHECK(!owner->result_ok);
7912         return SemanticError_clone(&*owner->contents.err);
7913 }
7914 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7915         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7916         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
7917         return ret_conv;
7918 }
7919
7920 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7921 CHECK(owner->result_ok);
7922         return Invoice_clone(&*owner->contents.result);
7923 }
7924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7925         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7926         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
7927         int64_t ret_ref = 0;
7928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7931         ret_ref = (uintptr_t)ret_var.inner;
7932         if (ret_var.is_owned) {
7933                 ret_ref |= 1;
7934         }
7935         return ret_ref;
7936 }
7937
7938 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7939 CHECK(!owner->result_ok);
7940         return SemanticError_clone(&*owner->contents.err);
7941 }
7942 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7943         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7944         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
7945         return ret_conv;
7946 }
7947
7948 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7949 CHECK(owner->result_ok);
7950         return Description_clone(&*owner->contents.result);
7951 }
7952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7953         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7954         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
7955         int64_t ret_ref = 0;
7956         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7957         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7959         ret_ref = (uintptr_t)ret_var.inner;
7960         if (ret_var.is_owned) {
7961                 ret_ref |= 1;
7962         }
7963         return ret_ref;
7964 }
7965
7966 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7967 CHECK(!owner->result_ok);
7968         return CreationError_clone(&*owner->contents.err);
7969 }
7970 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7971         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7972         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
7973         return ret_conv;
7974 }
7975
7976 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7977 CHECK(owner->result_ok);
7978         return PrivateRoute_clone(&*owner->contents.result);
7979 }
7980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7981         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
7982         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
7983         int64_t ret_ref = 0;
7984         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7985         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7987         ret_ref = (uintptr_t)ret_var.inner;
7988         if (ret_var.is_owned) {
7989                 ret_ref |= 1;
7990         }
7991         return ret_ref;
7992 }
7993
7994 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7995 CHECK(!owner->result_ok);
7996         return CreationError_clone(&*owner->contents.err);
7997 }
7998 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7999         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
8000         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
8001         return ret_conv;
8002 }
8003
8004 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8005 CHECK(owner->result_ok);
8006         return *owner->contents.result;
8007 }
8008 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8009         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
8010         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
8011         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8012         return ret_conv;
8013 }
8014
8015 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8016 CHECK(!owner->result_ok);
8017         return *owner->contents.err;
8018 }
8019 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8020         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
8021         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
8022         return ret_conv;
8023 }
8024
8025 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8026 CHECK(owner->result_ok);
8027         return ChannelMonitorUpdate_clone(&*owner->contents.result);
8028 }
8029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8030         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
8031         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
8032         int64_t ret_ref = 0;
8033         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8034         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8036         ret_ref = (uintptr_t)ret_var.inner;
8037         if (ret_var.is_owned) {
8038                 ret_ref |= 1;
8039         }
8040         return ret_ref;
8041 }
8042
8043 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8044 CHECK(!owner->result_ok);
8045         return DecodeError_clone(&*owner->contents.err);
8046 }
8047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8048         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
8049         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
8050         int64_t ret_ref = 0;
8051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8054         ret_ref = (uintptr_t)ret_var.inner;
8055         if (ret_var.is_owned) {
8056                 ret_ref |= 1;
8057         }
8058         return ret_ref;
8059 }
8060
8061 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
8062 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
8063 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
8064 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
8065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
8066         LDKCOption_MonitorEventZ_Some_class =
8067                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
8068         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
8069         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
8070         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
8071         LDKCOption_MonitorEventZ_None_class =
8072                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
8073         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
8074         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
8075         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
8076 }
8077 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8078         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
8079         switch(obj->tag) {
8080                 case LDKCOption_MonitorEventZ_Some: {
8081                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
8082                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
8083                 }
8084                 case LDKCOption_MonitorEventZ_None: {
8085                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
8086                 }
8087                 default: abort();
8088         }
8089 }
8090 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8091 CHECK(owner->result_ok);
8092         return COption_MonitorEventZ_clone(&*owner->contents.result);
8093 }
8094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8095         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
8096         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
8097         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
8098         int64_t ret_ref = (uintptr_t)ret_copy;
8099         return ret_ref;
8100 }
8101
8102 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8103 CHECK(!owner->result_ok);
8104         return DecodeError_clone(&*owner->contents.err);
8105 }
8106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8107         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
8108         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
8109         int64_t ret_ref = 0;
8110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8113         ret_ref = (uintptr_t)ret_var.inner;
8114         if (ret_var.is_owned) {
8115                 ret_ref |= 1;
8116         }
8117         return ret_ref;
8118 }
8119
8120 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8121 CHECK(owner->result_ok);
8122         return HTLCUpdate_clone(&*owner->contents.result);
8123 }
8124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8125         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8126         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
8127         int64_t ret_ref = 0;
8128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8131         ret_ref = (uintptr_t)ret_var.inner;
8132         if (ret_var.is_owned) {
8133                 ret_ref |= 1;
8134         }
8135         return ret_ref;
8136 }
8137
8138 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8139 CHECK(!owner->result_ok);
8140         return DecodeError_clone(&*owner->contents.err);
8141 }
8142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8143         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
8144         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
8145         int64_t ret_ref = 0;
8146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8149         ret_ref = (uintptr_t)ret_var.inner;
8150         if (ret_var.is_owned) {
8151                 ret_ref |= 1;
8152         }
8153         return ret_ref;
8154 }
8155
8156 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8157         return OutPoint_clone(&owner->a);
8158 }
8159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8160         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8161         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
8162         int64_t ret_ref = 0;
8163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8166         ret_ref = (uintptr_t)ret_var.inner;
8167         if (ret_var.is_owned) {
8168                 ret_ref |= 1;
8169         }
8170         return ret_ref;
8171 }
8172
8173 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8174         return CVec_u8Z_clone(&owner->b);
8175 }
8176 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8177         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
8178         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
8179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8181         CVec_u8Z_free(ret_var);
8182         return ret_arr;
8183 }
8184
8185 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8186         return owner->a;
8187 }
8188 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8189         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8190         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
8191         return ret_conv;
8192 }
8193
8194 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8195         return CVec_u8Z_clone(&owner->b);
8196 }
8197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8198         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
8199         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
8200         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8201         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8202         CVec_u8Z_free(ret_var);
8203         return ret_arr;
8204 }
8205
8206 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
8207         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
8208         for (size_t i = 0; i < ret.datalen; i++) {
8209                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
8210         }
8211         return ret;
8212 }
8213 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8214         return ThirtyTwoBytes_clone(&owner->a);
8215 }
8216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8217         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8218         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8219         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
8220         return ret_arr;
8221 }
8222
8223 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8224         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
8225 }
8226 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8227         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
8228         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
8229         int64_tArray ret_arr = NULL;
8230         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8231         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8232         for (size_t v = 0; v < ret_var.datalen; v++) {
8233                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8234                 *ret_conv_21_conv = ret_var.data[v];
8235                 ret_arr_ptr[v] = ((int64_t)ret_conv_21_conv);
8236         }
8237         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8238         FREE(ret_var.data);
8239         return ret_arr;
8240 }
8241
8242 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
8243         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 };
8244         for (size_t i = 0; i < ret.datalen; i++) {
8245                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
8246         }
8247         return ret;
8248 }
8249 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
8250         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
8251         for (size_t i = 0; i < ret.datalen; i++) {
8252                 ret.data[i] = Event_clone(&orig->data[i]);
8253         }
8254         return ret;
8255 }
8256 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8257         return owner->a;
8258 }
8259 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8260         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8261         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
8262         return ret_conv;
8263 }
8264
8265 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8266         return TxOut_clone(&owner->b);
8267 }
8268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8269         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
8270         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8271         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
8272         return (int64_t)ret_ref;
8273 }
8274
8275 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
8276         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
8277         for (size_t i = 0; i < ret.datalen; i++) {
8278                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
8279         }
8280         return ret;
8281 }
8282 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8283         return ThirtyTwoBytes_clone(&owner->a);
8284 }
8285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8286         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8287         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
8289         return ret_arr;
8290 }
8291
8292 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8293         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
8294 }
8295 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8296         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
8297         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
8298         int64_tArray ret_arr = NULL;
8299         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8300         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8301         for (size_t u = 0; u < ret_var.datalen; u++) {
8302                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8303                 *ret_conv_20_conv = ret_var.data[u];
8304                 ret_arr_ptr[u] = ((int64_t)ret_conv_20_conv);
8305         }
8306         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8307         FREE(ret_var.data);
8308         return ret_arr;
8309 }
8310
8311 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
8312         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 };
8313         for (size_t i = 0; i < ret.datalen; i++) {
8314                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
8315         }
8316         return ret;
8317 }
8318 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
8319 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
8320 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
8321 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
8322 static jclass LDKBalance_ContentiousClaimable_class = NULL;
8323 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
8324 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
8325 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
8326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
8327         LDKBalance_ClaimableOnChannelClose_class =
8328                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
8329         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
8330         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
8331         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
8332         LDKBalance_ClaimableAwaitingConfirmations_class =
8333                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
8334         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
8335         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
8336         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
8337         LDKBalance_ContentiousClaimable_class =
8338                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
8339         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
8340         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
8341         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
8342         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
8343                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
8344         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
8345         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
8346         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
8347 }
8348 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8349         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
8350         switch(obj->tag) {
8351                 case LDKBalance_ClaimableOnChannelClose: {
8352                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
8353                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
8354                 }
8355                 case LDKBalance_ClaimableAwaitingConfirmations: {
8356                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
8357                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
8358                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
8359                 }
8360                 case LDKBalance_ContentiousClaimable: {
8361                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
8362                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
8363                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
8364                 }
8365                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
8366                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
8367                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
8368                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, claimable_amount_satoshis_conv, claimable_height_conv);
8369                 }
8370                 default: abort();
8371         }
8372 }
8373 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
8374         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
8375         for (size_t i = 0; i < ret.datalen; i++) {
8376                 ret.data[i] = Balance_clone(&orig->data[i]);
8377         }
8378         return ret;
8379 }
8380 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8381 CHECK(owner->result_ok);
8382         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
8383 }
8384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8385         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8386         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8387         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
8388         return ((int64_t)ret_conv);
8389 }
8390
8391 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8392 CHECK(!owner->result_ok);
8393         return DecodeError_clone(&*owner->contents.err);
8394 }
8395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8396         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
8397         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
8398         int64_t ret_ref = 0;
8399         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8400         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8402         ret_ref = (uintptr_t)ret_var.inner;
8403         if (ret_var.is_owned) {
8404                 ret_ref |= 1;
8405         }
8406         return ret_ref;
8407 }
8408
8409 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8410         return owner->a;
8411 }
8412 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8413         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8414         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8415         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
8416         return ret_arr;
8417 }
8418
8419 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8420         return Type_clone(&owner->b);
8421 }
8422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8423         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
8424         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
8425         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
8426         return (int64_t)ret_ret;
8427 }
8428
8429 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
8430         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
8431         for (size_t i = 0; i < ret.datalen; i++) {
8432                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
8433         }
8434         return ret;
8435 }
8436 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
8437 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
8438 static jclass LDKCOption_NetAddressZ_None_class = NULL;
8439 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
8440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
8441         LDKCOption_NetAddressZ_Some_class =
8442                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
8443         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
8444         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
8445         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
8446         LDKCOption_NetAddressZ_None_class =
8447                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
8448         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
8449         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
8450         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
8451 }
8452 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8453         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
8454         switch(obj->tag) {
8455                 case LDKCOption_NetAddressZ_Some: {
8456                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
8457                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
8458                 }
8459                 case LDKCOption_NetAddressZ_None: {
8460                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
8461                 }
8462                 default: abort();
8463         }
8464 }
8465 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8466 CHECK(owner->result_ok);
8467         return CVec_u8Z_clone(&*owner->contents.result);
8468 }
8469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8470         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8471         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
8472         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8473         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8474         CVec_u8Z_free(ret_var);
8475         return ret_arr;
8476 }
8477
8478 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8479 CHECK(!owner->result_ok);
8480         return PeerHandleError_clone(&*owner->contents.err);
8481 }
8482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8483         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
8484         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
8485         int64_t ret_ref = 0;
8486         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8487         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8489         ret_ref = (uintptr_t)ret_var.inner;
8490         if (ret_var.is_owned) {
8491                 ret_ref |= 1;
8492         }
8493         return ret_ref;
8494 }
8495
8496 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8497 CHECK(owner->result_ok);
8498         return *owner->contents.result;
8499 }
8500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8501         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8502         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
8503 }
8504
8505 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8506 CHECK(!owner->result_ok);
8507         return PeerHandleError_clone(&*owner->contents.err);
8508 }
8509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8510         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
8511         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
8512         int64_t ret_ref = 0;
8513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8516         ret_ref = (uintptr_t)ret_var.inner;
8517         if (ret_var.is_owned) {
8518                 ret_ref |= 1;
8519         }
8520         return ret_ref;
8521 }
8522
8523 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8524 CHECK(owner->result_ok);
8525         return *owner->contents.result;
8526 }
8527 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8528         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8529         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
8530         return ret_conv;
8531 }
8532
8533 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8534 CHECK(!owner->result_ok);
8535         return PeerHandleError_clone(&*owner->contents.err);
8536 }
8537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8538         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
8539         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
8540         int64_t ret_ref = 0;
8541         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8542         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8544         ret_ref = (uintptr_t)ret_var.inner;
8545         if (ret_var.is_owned) {
8546                 ret_ref |= 1;
8547         }
8548         return ret_ref;
8549 }
8550
8551 static jclass LDKGraphSyncError_DecodeError_class = NULL;
8552 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
8553 static jclass LDKGraphSyncError_LightningError_class = NULL;
8554 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
8555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
8556         LDKGraphSyncError_DecodeError_class =
8557                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
8558         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
8559         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
8560         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
8561         LDKGraphSyncError_LightningError_class =
8562                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
8563         CHECK(LDKGraphSyncError_LightningError_class != NULL);
8564         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
8565         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
8566 }
8567 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8568         LDKGraphSyncError *obj = (LDKGraphSyncError*)(ptr & ~1);
8569         switch(obj->tag) {
8570                 case LDKGraphSyncError_DecodeError: {
8571                         LDKDecodeError decode_error_var = obj->decode_error;
8572                         int64_t decode_error_ref = 0;
8573                         CHECK((((uintptr_t)decode_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8574                         CHECK((((uintptr_t)&decode_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8575                         CHECK_INNER_FIELD_ACCESS_OR_NULL(decode_error_var);
8576                         decode_error_ref = (uintptr_t)decode_error_var.inner & ~1;
8577                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
8578                 }
8579                 case LDKGraphSyncError_LightningError: {
8580                         LDKLightningError lightning_error_var = obj->lightning_error;
8581                         int64_t lightning_error_ref = 0;
8582                         CHECK((((uintptr_t)lightning_error_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8583                         CHECK((((uintptr_t)&lightning_error_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8584                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
8585                         lightning_error_ref = (uintptr_t)lightning_error_var.inner & ~1;
8586                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
8587                 }
8588                 default: abort();
8589         }
8590 }
8591 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8592 CHECK(owner->result_ok);
8593         return *owner->contents.result;
8594 }
8595 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8596         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8597         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
8598         return ret_conv;
8599 }
8600
8601 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
8602 CHECK(!owner->result_ok);
8603         return GraphSyncError_clone(&*owner->contents.err);
8604 }
8605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8606         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)(owner & ~1);
8607         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
8608         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
8609         int64_t ret_ref = (uintptr_t)ret_copy;
8610         return ret_ref;
8611 }
8612
8613 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8614 CHECK(owner->result_ok);
8615         return NetAddress_clone(&*owner->contents.result);
8616 }
8617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8618         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8619         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8620         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8621         int64_t ret_ref = (uintptr_t)ret_copy;
8622         return ret_ref;
8623 }
8624
8625 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8626 CHECK(!owner->result_ok);
8627         return DecodeError_clone(&*owner->contents.err);
8628 }
8629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8630         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8631         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8632         int64_t ret_ref = 0;
8633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8636         ret_ref = (uintptr_t)ret_var.inner;
8637         if (ret_var.is_owned) {
8638                 ret_ref |= 1;
8639         }
8640         return ret_ref;
8641 }
8642
8643 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8644         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8645         for (size_t i = 0; i < ret.datalen; i++) {
8646                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8647         }
8648         return ret;
8649 }
8650 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8651         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8652         for (size_t i = 0; i < ret.datalen; i++) {
8653                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8654         }
8655         return ret;
8656 }
8657 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8658         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8659         for (size_t i = 0; i < ret.datalen; i++) {
8660                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8661         }
8662         return ret;
8663 }
8664 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8665         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8666         for (size_t i = 0; i < ret.datalen; i++) {
8667                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8668         }
8669         return ret;
8670 }
8671 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8672 CHECK(owner->result_ok);
8673         return AcceptChannel_clone(&*owner->contents.result);
8674 }
8675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8676         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8677         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8678         int64_t ret_ref = 0;
8679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8682         ret_ref = (uintptr_t)ret_var.inner;
8683         if (ret_var.is_owned) {
8684                 ret_ref |= 1;
8685         }
8686         return ret_ref;
8687 }
8688
8689 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8690 CHECK(!owner->result_ok);
8691         return DecodeError_clone(&*owner->contents.err);
8692 }
8693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8694         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8695         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8696         int64_t ret_ref = 0;
8697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8700         ret_ref = (uintptr_t)ret_var.inner;
8701         if (ret_var.is_owned) {
8702                 ret_ref |= 1;
8703         }
8704         return ret_ref;
8705 }
8706
8707 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8708 CHECK(owner->result_ok);
8709         return AnnouncementSignatures_clone(&*owner->contents.result);
8710 }
8711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8712         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8713         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8714         int64_t ret_ref = 0;
8715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8718         ret_ref = (uintptr_t)ret_var.inner;
8719         if (ret_var.is_owned) {
8720                 ret_ref |= 1;
8721         }
8722         return ret_ref;
8723 }
8724
8725 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8726 CHECK(!owner->result_ok);
8727         return DecodeError_clone(&*owner->contents.err);
8728 }
8729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8730         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8731         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8732         int64_t ret_ref = 0;
8733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8736         ret_ref = (uintptr_t)ret_var.inner;
8737         if (ret_var.is_owned) {
8738                 ret_ref |= 1;
8739         }
8740         return ret_ref;
8741 }
8742
8743 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8744 CHECK(owner->result_ok);
8745         return ChannelReestablish_clone(&*owner->contents.result);
8746 }
8747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8748         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8749         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8750         int64_t ret_ref = 0;
8751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8754         ret_ref = (uintptr_t)ret_var.inner;
8755         if (ret_var.is_owned) {
8756                 ret_ref |= 1;
8757         }
8758         return ret_ref;
8759 }
8760
8761 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8762 CHECK(!owner->result_ok);
8763         return DecodeError_clone(&*owner->contents.err);
8764 }
8765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8766         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8767         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8768         int64_t ret_ref = 0;
8769         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8770         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8772         ret_ref = (uintptr_t)ret_var.inner;
8773         if (ret_var.is_owned) {
8774                 ret_ref |= 1;
8775         }
8776         return ret_ref;
8777 }
8778
8779 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8780 CHECK(owner->result_ok);
8781         return ClosingSigned_clone(&*owner->contents.result);
8782 }
8783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8784         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8785         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8786         int64_t ret_ref = 0;
8787         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8788         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8790         ret_ref = (uintptr_t)ret_var.inner;
8791         if (ret_var.is_owned) {
8792                 ret_ref |= 1;
8793         }
8794         return ret_ref;
8795 }
8796
8797 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8798 CHECK(!owner->result_ok);
8799         return DecodeError_clone(&*owner->contents.err);
8800 }
8801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8802         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8803         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
8804         int64_t ret_ref = 0;
8805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8808         ret_ref = (uintptr_t)ret_var.inner;
8809         if (ret_var.is_owned) {
8810                 ret_ref |= 1;
8811         }
8812         return ret_ref;
8813 }
8814
8815 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8816 CHECK(owner->result_ok);
8817         return ClosingSignedFeeRange_clone(&*owner->contents.result);
8818 }
8819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8820         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8821         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
8822         int64_t ret_ref = 0;
8823         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8824         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8826         ret_ref = (uintptr_t)ret_var.inner;
8827         if (ret_var.is_owned) {
8828                 ret_ref |= 1;
8829         }
8830         return ret_ref;
8831 }
8832
8833 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8834 CHECK(!owner->result_ok);
8835         return DecodeError_clone(&*owner->contents.err);
8836 }
8837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8838         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8839         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
8840         int64_t ret_ref = 0;
8841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8844         ret_ref = (uintptr_t)ret_var.inner;
8845         if (ret_var.is_owned) {
8846                 ret_ref |= 1;
8847         }
8848         return ret_ref;
8849 }
8850
8851 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8852 CHECK(owner->result_ok);
8853         return CommitmentSigned_clone(&*owner->contents.result);
8854 }
8855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8856         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8857         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
8858         int64_t ret_ref = 0;
8859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8862         ret_ref = (uintptr_t)ret_var.inner;
8863         if (ret_var.is_owned) {
8864                 ret_ref |= 1;
8865         }
8866         return ret_ref;
8867 }
8868
8869 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8870 CHECK(!owner->result_ok);
8871         return DecodeError_clone(&*owner->contents.err);
8872 }
8873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8874         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8875         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
8876         int64_t ret_ref = 0;
8877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8880         ret_ref = (uintptr_t)ret_var.inner;
8881         if (ret_var.is_owned) {
8882                 ret_ref |= 1;
8883         }
8884         return ret_ref;
8885 }
8886
8887 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8888 CHECK(owner->result_ok);
8889         return FundingCreated_clone(&*owner->contents.result);
8890 }
8891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8892         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8893         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
8894         int64_t ret_ref = 0;
8895         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8896         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8898         ret_ref = (uintptr_t)ret_var.inner;
8899         if (ret_var.is_owned) {
8900                 ret_ref |= 1;
8901         }
8902         return ret_ref;
8903 }
8904
8905 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8906 CHECK(!owner->result_ok);
8907         return DecodeError_clone(&*owner->contents.err);
8908 }
8909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8910         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8911         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
8912         int64_t ret_ref = 0;
8913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8916         ret_ref = (uintptr_t)ret_var.inner;
8917         if (ret_var.is_owned) {
8918                 ret_ref |= 1;
8919         }
8920         return ret_ref;
8921 }
8922
8923 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8924 CHECK(owner->result_ok);
8925         return FundingSigned_clone(&*owner->contents.result);
8926 }
8927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8928         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8929         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
8930         int64_t ret_ref = 0;
8931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8934         ret_ref = (uintptr_t)ret_var.inner;
8935         if (ret_var.is_owned) {
8936                 ret_ref |= 1;
8937         }
8938         return ret_ref;
8939 }
8940
8941 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8942 CHECK(!owner->result_ok);
8943         return DecodeError_clone(&*owner->contents.err);
8944 }
8945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8946         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8947         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
8948         int64_t ret_ref = 0;
8949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8952         ret_ref = (uintptr_t)ret_var.inner;
8953         if (ret_var.is_owned) {
8954                 ret_ref |= 1;
8955         }
8956         return ret_ref;
8957 }
8958
8959 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8960 CHECK(owner->result_ok);
8961         return ChannelReady_clone(&*owner->contents.result);
8962 }
8963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8964         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
8965         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
8966         int64_t ret_ref = 0;
8967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8970         ret_ref = (uintptr_t)ret_var.inner;
8971         if (ret_var.is_owned) {
8972                 ret_ref |= 1;
8973         }
8974         return ret_ref;
8975 }
8976
8977 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8978 CHECK(!owner->result_ok);
8979         return DecodeError_clone(&*owner->contents.err);
8980 }
8981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8982         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
8983         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
8984         int64_t ret_ref = 0;
8985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8988         ret_ref = (uintptr_t)ret_var.inner;
8989         if (ret_var.is_owned) {
8990                 ret_ref |= 1;
8991         }
8992         return ret_ref;
8993 }
8994
8995 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8996 CHECK(owner->result_ok);
8997         return Init_clone(&*owner->contents.result);
8998 }
8999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9000         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
9001         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
9002         int64_t ret_ref = 0;
9003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9006         ret_ref = (uintptr_t)ret_var.inner;
9007         if (ret_var.is_owned) {
9008                 ret_ref |= 1;
9009         }
9010         return ret_ref;
9011 }
9012
9013 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9014 CHECK(!owner->result_ok);
9015         return DecodeError_clone(&*owner->contents.err);
9016 }
9017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9018         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
9019         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
9020         int64_t ret_ref = 0;
9021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9024         ret_ref = (uintptr_t)ret_var.inner;
9025         if (ret_var.is_owned) {
9026                 ret_ref |= 1;
9027         }
9028         return ret_ref;
9029 }
9030
9031 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9032 CHECK(owner->result_ok);
9033         return OpenChannel_clone(&*owner->contents.result);
9034 }
9035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9036         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
9037         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
9038         int64_t ret_ref = 0;
9039         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9040         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9042         ret_ref = (uintptr_t)ret_var.inner;
9043         if (ret_var.is_owned) {
9044                 ret_ref |= 1;
9045         }
9046         return ret_ref;
9047 }
9048
9049 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9050 CHECK(!owner->result_ok);
9051         return DecodeError_clone(&*owner->contents.err);
9052 }
9053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9054         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
9055         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
9056         int64_t ret_ref = 0;
9057         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9058         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9060         ret_ref = (uintptr_t)ret_var.inner;
9061         if (ret_var.is_owned) {
9062                 ret_ref |= 1;
9063         }
9064         return ret_ref;
9065 }
9066
9067 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9068 CHECK(owner->result_ok);
9069         return RevokeAndACK_clone(&*owner->contents.result);
9070 }
9071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9072         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
9073         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
9074         int64_t ret_ref = 0;
9075         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9076         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9078         ret_ref = (uintptr_t)ret_var.inner;
9079         if (ret_var.is_owned) {
9080                 ret_ref |= 1;
9081         }
9082         return ret_ref;
9083 }
9084
9085 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9086 CHECK(!owner->result_ok);
9087         return DecodeError_clone(&*owner->contents.err);
9088 }
9089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9090         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
9091         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
9092         int64_t ret_ref = 0;
9093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9096         ret_ref = (uintptr_t)ret_var.inner;
9097         if (ret_var.is_owned) {
9098                 ret_ref |= 1;
9099         }
9100         return ret_ref;
9101 }
9102
9103 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9104 CHECK(owner->result_ok);
9105         return Shutdown_clone(&*owner->contents.result);
9106 }
9107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9108         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9109         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
9110         int64_t ret_ref = 0;
9111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9114         ret_ref = (uintptr_t)ret_var.inner;
9115         if (ret_var.is_owned) {
9116                 ret_ref |= 1;
9117         }
9118         return ret_ref;
9119 }
9120
9121 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9122 CHECK(!owner->result_ok);
9123         return DecodeError_clone(&*owner->contents.err);
9124 }
9125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9126         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
9127         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
9128         int64_t ret_ref = 0;
9129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9132         ret_ref = (uintptr_t)ret_var.inner;
9133         if (ret_var.is_owned) {
9134                 ret_ref |= 1;
9135         }
9136         return ret_ref;
9137 }
9138
9139 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9140 CHECK(owner->result_ok);
9141         return UpdateFailHTLC_clone(&*owner->contents.result);
9142 }
9143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9144         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9145         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
9146         int64_t ret_ref = 0;
9147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9150         ret_ref = (uintptr_t)ret_var.inner;
9151         if (ret_var.is_owned) {
9152                 ret_ref |= 1;
9153         }
9154         return ret_ref;
9155 }
9156
9157 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9158 CHECK(!owner->result_ok);
9159         return DecodeError_clone(&*owner->contents.err);
9160 }
9161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9162         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
9163         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
9164         int64_t ret_ref = 0;
9165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9168         ret_ref = (uintptr_t)ret_var.inner;
9169         if (ret_var.is_owned) {
9170                 ret_ref |= 1;
9171         }
9172         return ret_ref;
9173 }
9174
9175 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9176 CHECK(owner->result_ok);
9177         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
9178 }
9179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9180         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9181         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
9182         int64_t ret_ref = 0;
9183         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9184         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9186         ret_ref = (uintptr_t)ret_var.inner;
9187         if (ret_var.is_owned) {
9188                 ret_ref |= 1;
9189         }
9190         return ret_ref;
9191 }
9192
9193 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9194 CHECK(!owner->result_ok);
9195         return DecodeError_clone(&*owner->contents.err);
9196 }
9197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9198         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9199         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
9200         int64_t ret_ref = 0;
9201         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9202         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9204         ret_ref = (uintptr_t)ret_var.inner;
9205         if (ret_var.is_owned) {
9206                 ret_ref |= 1;
9207         }
9208         return ret_ref;
9209 }
9210
9211 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9212 CHECK(owner->result_ok);
9213         return UpdateFee_clone(&*owner->contents.result);
9214 }
9215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9216         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9217         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
9218         int64_t ret_ref = 0;
9219         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9220         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9222         ret_ref = (uintptr_t)ret_var.inner;
9223         if (ret_var.is_owned) {
9224                 ret_ref |= 1;
9225         }
9226         return ret_ref;
9227 }
9228
9229 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9230 CHECK(!owner->result_ok);
9231         return DecodeError_clone(&*owner->contents.err);
9232 }
9233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9234         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9235         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9236         int64_t ret_ref = 0;
9237         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9238         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9240         ret_ref = (uintptr_t)ret_var.inner;
9241         if (ret_var.is_owned) {
9242                 ret_ref |= 1;
9243         }
9244         return ret_ref;
9245 }
9246
9247 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9248 CHECK(owner->result_ok);
9249         return UpdateFulfillHTLC_clone(&*owner->contents.result);
9250 }
9251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9252         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9253         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9254         int64_t ret_ref = 0;
9255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9258         ret_ref = (uintptr_t)ret_var.inner;
9259         if (ret_var.is_owned) {
9260                 ret_ref |= 1;
9261         }
9262         return ret_ref;
9263 }
9264
9265 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9266 CHECK(!owner->result_ok);
9267         return DecodeError_clone(&*owner->contents.err);
9268 }
9269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9270         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9271         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9272         int64_t ret_ref = 0;
9273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9276         ret_ref = (uintptr_t)ret_var.inner;
9277         if (ret_var.is_owned) {
9278                 ret_ref |= 1;
9279         }
9280         return ret_ref;
9281 }
9282
9283 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9284 CHECK(owner->result_ok);
9285         return UpdateAddHTLC_clone(&*owner->contents.result);
9286 }
9287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9288         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9289         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9290         int64_t ret_ref = 0;
9291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9294         ret_ref = (uintptr_t)ret_var.inner;
9295         if (ret_var.is_owned) {
9296                 ret_ref |= 1;
9297         }
9298         return ret_ref;
9299 }
9300
9301 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9302 CHECK(!owner->result_ok);
9303         return DecodeError_clone(&*owner->contents.err);
9304 }
9305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9306         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9307         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9308         int64_t ret_ref = 0;
9309         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9310         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9312         ret_ref = (uintptr_t)ret_var.inner;
9313         if (ret_var.is_owned) {
9314                 ret_ref |= 1;
9315         }
9316         return ret_ref;
9317 }
9318
9319 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9320 CHECK(owner->result_ok);
9321         return Ping_clone(&*owner->contents.result);
9322 }
9323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9324         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9325         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9326         int64_t ret_ref = 0;
9327         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9328         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9330         ret_ref = (uintptr_t)ret_var.inner;
9331         if (ret_var.is_owned) {
9332                 ret_ref |= 1;
9333         }
9334         return ret_ref;
9335 }
9336
9337 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9338 CHECK(!owner->result_ok);
9339         return DecodeError_clone(&*owner->contents.err);
9340 }
9341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9342         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9343         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
9344         int64_t ret_ref = 0;
9345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9348         ret_ref = (uintptr_t)ret_var.inner;
9349         if (ret_var.is_owned) {
9350                 ret_ref |= 1;
9351         }
9352         return ret_ref;
9353 }
9354
9355 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9356 CHECK(owner->result_ok);
9357         return Pong_clone(&*owner->contents.result);
9358 }
9359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9360         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9361         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9362         int64_t ret_ref = 0;
9363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9366         ret_ref = (uintptr_t)ret_var.inner;
9367         if (ret_var.is_owned) {
9368                 ret_ref |= 1;
9369         }
9370         return ret_ref;
9371 }
9372
9373 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9374 CHECK(!owner->result_ok);
9375         return DecodeError_clone(&*owner->contents.err);
9376 }
9377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9378         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9379         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
9380         int64_t ret_ref = 0;
9381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9384         ret_ref = (uintptr_t)ret_var.inner;
9385         if (ret_var.is_owned) {
9386                 ret_ref |= 1;
9387         }
9388         return ret_ref;
9389 }
9390
9391 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9392 CHECK(owner->result_ok);
9393         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
9394 }
9395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9396         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9397         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9398         int64_t ret_ref = 0;
9399         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9400         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9402         ret_ref = (uintptr_t)ret_var.inner;
9403         if (ret_var.is_owned) {
9404                 ret_ref |= 1;
9405         }
9406         return ret_ref;
9407 }
9408
9409 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9410 CHECK(!owner->result_ok);
9411         return DecodeError_clone(&*owner->contents.err);
9412 }
9413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9414         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9415         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9416         int64_t ret_ref = 0;
9417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9420         ret_ref = (uintptr_t)ret_var.inner;
9421         if (ret_var.is_owned) {
9422                 ret_ref |= 1;
9423         }
9424         return ret_ref;
9425 }
9426
9427 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9428 CHECK(owner->result_ok);
9429         return ChannelAnnouncement_clone(&*owner->contents.result);
9430 }
9431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9432         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9433         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9434         int64_t ret_ref = 0;
9435         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9436         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9438         ret_ref = (uintptr_t)ret_var.inner;
9439         if (ret_var.is_owned) {
9440                 ret_ref |= 1;
9441         }
9442         return ret_ref;
9443 }
9444
9445 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9446 CHECK(!owner->result_ok);
9447         return DecodeError_clone(&*owner->contents.err);
9448 }
9449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9450         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9451         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9452         int64_t ret_ref = 0;
9453         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9454         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9456         ret_ref = (uintptr_t)ret_var.inner;
9457         if (ret_var.is_owned) {
9458                 ret_ref |= 1;
9459         }
9460         return ret_ref;
9461 }
9462
9463 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9464 CHECK(owner->result_ok);
9465         return UnsignedChannelUpdate_clone(&*owner->contents.result);
9466 }
9467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9468         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9469         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9470         int64_t ret_ref = 0;
9471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9474         ret_ref = (uintptr_t)ret_var.inner;
9475         if (ret_var.is_owned) {
9476                 ret_ref |= 1;
9477         }
9478         return ret_ref;
9479 }
9480
9481 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9482 CHECK(!owner->result_ok);
9483         return DecodeError_clone(&*owner->contents.err);
9484 }
9485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9486         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9487         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
9488         int64_t ret_ref = 0;
9489         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9490         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9492         ret_ref = (uintptr_t)ret_var.inner;
9493         if (ret_var.is_owned) {
9494                 ret_ref |= 1;
9495         }
9496         return ret_ref;
9497 }
9498
9499 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9500 CHECK(owner->result_ok);
9501         return ChannelUpdate_clone(&*owner->contents.result);
9502 }
9503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9504         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9505         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9506         int64_t ret_ref = 0;
9507         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9508         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9510         ret_ref = (uintptr_t)ret_var.inner;
9511         if (ret_var.is_owned) {
9512                 ret_ref |= 1;
9513         }
9514         return ret_ref;
9515 }
9516
9517 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9518 CHECK(!owner->result_ok);
9519         return DecodeError_clone(&*owner->contents.err);
9520 }
9521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9522         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9523         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9524         int64_t ret_ref = 0;
9525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9528         ret_ref = (uintptr_t)ret_var.inner;
9529         if (ret_var.is_owned) {
9530                 ret_ref |= 1;
9531         }
9532         return ret_ref;
9533 }
9534
9535 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9536 CHECK(owner->result_ok);
9537         return ErrorMessage_clone(&*owner->contents.result);
9538 }
9539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9540         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9541         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9542         int64_t ret_ref = 0;
9543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9546         ret_ref = (uintptr_t)ret_var.inner;
9547         if (ret_var.is_owned) {
9548                 ret_ref |= 1;
9549         }
9550         return ret_ref;
9551 }
9552
9553 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9554 CHECK(!owner->result_ok);
9555         return DecodeError_clone(&*owner->contents.err);
9556 }
9557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9558         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9559         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9560         int64_t ret_ref = 0;
9561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9564         ret_ref = (uintptr_t)ret_var.inner;
9565         if (ret_var.is_owned) {
9566                 ret_ref |= 1;
9567         }
9568         return ret_ref;
9569 }
9570
9571 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9572 CHECK(owner->result_ok);
9573         return WarningMessage_clone(&*owner->contents.result);
9574 }
9575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9576         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9577         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9578         int64_t ret_ref = 0;
9579         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9580         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9582         ret_ref = (uintptr_t)ret_var.inner;
9583         if (ret_var.is_owned) {
9584                 ret_ref |= 1;
9585         }
9586         return ret_ref;
9587 }
9588
9589 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9590 CHECK(!owner->result_ok);
9591         return DecodeError_clone(&*owner->contents.err);
9592 }
9593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9594         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9595         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9596         int64_t ret_ref = 0;
9597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9600         ret_ref = (uintptr_t)ret_var.inner;
9601         if (ret_var.is_owned) {
9602                 ret_ref |= 1;
9603         }
9604         return ret_ref;
9605 }
9606
9607 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9608 CHECK(owner->result_ok);
9609         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
9610 }
9611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9612         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9613         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9614         int64_t ret_ref = 0;
9615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9618         ret_ref = (uintptr_t)ret_var.inner;
9619         if (ret_var.is_owned) {
9620                 ret_ref |= 1;
9621         }
9622         return ret_ref;
9623 }
9624
9625 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9626 CHECK(!owner->result_ok);
9627         return DecodeError_clone(&*owner->contents.err);
9628 }
9629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9630         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9631         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9632         int64_t ret_ref = 0;
9633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9636         ret_ref = (uintptr_t)ret_var.inner;
9637         if (ret_var.is_owned) {
9638                 ret_ref |= 1;
9639         }
9640         return ret_ref;
9641 }
9642
9643 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9644 CHECK(owner->result_ok);
9645         return NodeAnnouncement_clone(&*owner->contents.result);
9646 }
9647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9648         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9649         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9650         int64_t ret_ref = 0;
9651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9654         ret_ref = (uintptr_t)ret_var.inner;
9655         if (ret_var.is_owned) {
9656                 ret_ref |= 1;
9657         }
9658         return ret_ref;
9659 }
9660
9661 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9662 CHECK(!owner->result_ok);
9663         return DecodeError_clone(&*owner->contents.err);
9664 }
9665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9666         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9667         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9668         int64_t ret_ref = 0;
9669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9672         ret_ref = (uintptr_t)ret_var.inner;
9673         if (ret_var.is_owned) {
9674                 ret_ref |= 1;
9675         }
9676         return ret_ref;
9677 }
9678
9679 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9680 CHECK(owner->result_ok);
9681         return QueryShortChannelIds_clone(&*owner->contents.result);
9682 }
9683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9684         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9685         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9686         int64_t ret_ref = 0;
9687         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9688         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9690         ret_ref = (uintptr_t)ret_var.inner;
9691         if (ret_var.is_owned) {
9692                 ret_ref |= 1;
9693         }
9694         return ret_ref;
9695 }
9696
9697 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9698 CHECK(!owner->result_ok);
9699         return DecodeError_clone(&*owner->contents.err);
9700 }
9701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9702         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9703         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9704         int64_t ret_ref = 0;
9705         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9706         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9708         ret_ref = (uintptr_t)ret_var.inner;
9709         if (ret_var.is_owned) {
9710                 ret_ref |= 1;
9711         }
9712         return ret_ref;
9713 }
9714
9715 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9716 CHECK(owner->result_ok);
9717         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
9718 }
9719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9720         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9721         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9722         int64_t ret_ref = 0;
9723         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9724         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9726         ret_ref = (uintptr_t)ret_var.inner;
9727         if (ret_var.is_owned) {
9728                 ret_ref |= 1;
9729         }
9730         return ret_ref;
9731 }
9732
9733 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9734 CHECK(!owner->result_ok);
9735         return DecodeError_clone(&*owner->contents.err);
9736 }
9737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9738         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9739         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9740         int64_t ret_ref = 0;
9741         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9742         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9744         ret_ref = (uintptr_t)ret_var.inner;
9745         if (ret_var.is_owned) {
9746                 ret_ref |= 1;
9747         }
9748         return ret_ref;
9749 }
9750
9751 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9752 CHECK(owner->result_ok);
9753         return QueryChannelRange_clone(&*owner->contents.result);
9754 }
9755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9756         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9757         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9758         int64_t ret_ref = 0;
9759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9762         ret_ref = (uintptr_t)ret_var.inner;
9763         if (ret_var.is_owned) {
9764                 ret_ref |= 1;
9765         }
9766         return ret_ref;
9767 }
9768
9769 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9770 CHECK(!owner->result_ok);
9771         return DecodeError_clone(&*owner->contents.err);
9772 }
9773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9774         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9775         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9776         int64_t ret_ref = 0;
9777         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9778         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9780         ret_ref = (uintptr_t)ret_var.inner;
9781         if (ret_var.is_owned) {
9782                 ret_ref |= 1;
9783         }
9784         return ret_ref;
9785 }
9786
9787 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9788 CHECK(owner->result_ok);
9789         return ReplyChannelRange_clone(&*owner->contents.result);
9790 }
9791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9792         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9793         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9794         int64_t ret_ref = 0;
9795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9798         ret_ref = (uintptr_t)ret_var.inner;
9799         if (ret_var.is_owned) {
9800                 ret_ref |= 1;
9801         }
9802         return ret_ref;
9803 }
9804
9805 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9806 CHECK(!owner->result_ok);
9807         return DecodeError_clone(&*owner->contents.err);
9808 }
9809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9810         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9811         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
9812         int64_t ret_ref = 0;
9813         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9814         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9816         ret_ref = (uintptr_t)ret_var.inner;
9817         if (ret_var.is_owned) {
9818                 ret_ref |= 1;
9819         }
9820         return ret_ref;
9821 }
9822
9823 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9824 CHECK(owner->result_ok);
9825         return GossipTimestampFilter_clone(&*owner->contents.result);
9826 }
9827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9828         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9829         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
9830         int64_t ret_ref = 0;
9831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9834         ret_ref = (uintptr_t)ret_var.inner;
9835         if (ret_var.is_owned) {
9836                 ret_ref |= 1;
9837         }
9838         return ret_ref;
9839 }
9840
9841 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9842 CHECK(!owner->result_ok);
9843         return DecodeError_clone(&*owner->contents.err);
9844 }
9845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9846         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9847         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
9848         int64_t ret_ref = 0;
9849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9852         ret_ref = (uintptr_t)ret_var.inner;
9853         if (ret_var.is_owned) {
9854                 ret_ref |= 1;
9855         }
9856         return ret_ref;
9857 }
9858
9859 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
9860         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
9861         for (size_t i = 0; i < ret.datalen; i++) {
9862                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
9863         }
9864         return ret;
9865 }
9866 static jclass LDKSignOrCreationError_SignError_class = NULL;
9867 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
9868 static jclass LDKSignOrCreationError_CreationError_class = NULL;
9869 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
9870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
9871         LDKSignOrCreationError_SignError_class =
9872                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
9873         CHECK(LDKSignOrCreationError_SignError_class != NULL);
9874         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
9875         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
9876         LDKSignOrCreationError_CreationError_class =
9877                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
9878         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
9879         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
9880         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
9881 }
9882 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9883         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
9884         switch(obj->tag) {
9885                 case LDKSignOrCreationError_SignError: {
9886                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
9887                 }
9888                 case LDKSignOrCreationError_CreationError: {
9889                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
9890                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
9891                 }
9892                 default: abort();
9893         }
9894 }
9895 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9896 CHECK(owner->result_ok);
9897         return Invoice_clone(&*owner->contents.result);
9898 }
9899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9900         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9901         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
9902         int64_t ret_ref = 0;
9903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9906         ret_ref = (uintptr_t)ret_var.inner;
9907         if (ret_var.is_owned) {
9908                 ret_ref |= 1;
9909         }
9910         return ret_ref;
9911 }
9912
9913 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9914 CHECK(!owner->result_ok);
9915         return SignOrCreationError_clone(&*owner->contents.err);
9916 }
9917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9918         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9919         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
9920         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
9921         int64_t ret_ref = (uintptr_t)ret_copy;
9922         return ret_ref;
9923 }
9924
9925 typedef struct LDKFilter_JCalls {
9926         atomic_size_t refcnt;
9927         JavaVM *vm;
9928         jweak o;
9929         jmethodID register_tx_meth;
9930         jmethodID register_output_meth;
9931 } LDKFilter_JCalls;
9932 static void LDKFilter_JCalls_free(void* this_arg) {
9933         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9934         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9935                 JNIEnv *env;
9936                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9937                 if (get_jenv_res == JNI_EDETACHED) {
9938                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9939                 } else {
9940                         DO_ASSERT(get_jenv_res == JNI_OK);
9941                 }
9942                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9943                 if (get_jenv_res == JNI_EDETACHED) {
9944                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9945                 }
9946                 FREE(j_calls);
9947         }
9948 }
9949 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
9950         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9951         JNIEnv *env;
9952         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9953         if (get_jenv_res == JNI_EDETACHED) {
9954                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9955         } else {
9956                 DO_ASSERT(get_jenv_res == JNI_OK);
9957         }
9958         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
9959         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
9960         LDKu8slice script_pubkey_var = script_pubkey;
9961         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
9962         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
9963         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9964         CHECK(obj != NULL);
9965         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
9966         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9967                 (*env)->ExceptionDescribe(env);
9968                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
9969         }
9970         if (get_jenv_res == JNI_EDETACHED) {
9971                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9972         }
9973 }
9974 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
9975         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9976         JNIEnv *env;
9977         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9978         if (get_jenv_res == JNI_EDETACHED) {
9979                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9980         } else {
9981                 DO_ASSERT(get_jenv_res == JNI_OK);
9982         }
9983         LDKWatchedOutput output_var = output;
9984         int64_t output_ref = 0;
9985         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9986         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9987         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
9988         output_ref = (uintptr_t)output_var.inner;
9989         if (output_var.is_owned) {
9990                 output_ref |= 1;
9991         }
9992         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9993         CHECK(obj != NULL);
9994         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
9995         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9996                 (*env)->ExceptionDescribe(env);
9997                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
9998         }
9999         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10000         CHECK_ACCESS(ret_ptr);
10001         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
10002         FREE((void*)ret);
10003         if (get_jenv_res == JNI_EDETACHED) {
10004                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10005         }
10006         return ret_conv;
10007 }
10008 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
10009         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
10010         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10011 }
10012 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
10013         jclass c = (*env)->GetObjectClass(env, o);
10014         CHECK(c != NULL);
10015         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
10016         atomic_init(&calls->refcnt, 1);
10017         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10018         calls->o = (*env)->NewWeakGlobalRef(env, o);
10019         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
10020         CHECK(calls->register_tx_meth != NULL);
10021         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
10022         CHECK(calls->register_output_meth != NULL);
10023
10024         LDKFilter ret = {
10025                 .this_arg = (void*) calls,
10026                 .register_tx = register_tx_LDKFilter_jcall,
10027                 .register_output = register_output_LDKFilter_jcall,
10028                 .free = LDKFilter_JCalls_free,
10029         };
10030         return ret;
10031 }
10032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
10033         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10034         *res_ptr = LDKFilter_init(env, clz, o);
10035         return (uint64_t)res_ptr;
10036 }
10037 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) {
10038         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10039         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10040         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10041         unsigned char txid_arr[32];
10042         CHECK((*env)->GetArrayLength(env, txid) == 32);
10043         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10044         unsigned char (*txid_ref)[32] = &txid_arr;
10045         LDKu8slice script_pubkey_ref;
10046         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10047         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
10048         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
10049         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
10050 }
10051
10052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
10053         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10054         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10055         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10056         LDKWatchedOutput output_conv;
10057         output_conv.inner = (void*)(output & (~1));
10058         output_conv.is_owned = (output & 1) || (output == 0);
10059         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
10060         output_conv = WatchedOutput_clone(&output_conv);
10061         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
10062         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
10063         int64_t ret_ref = (uintptr_t)ret_copy;
10064         return ret_ref;
10065 }
10066
10067 static jclass LDKCOption_FilterZ_Some_class = NULL;
10068 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
10069 static jclass LDKCOption_FilterZ_None_class = NULL;
10070 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
10071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
10072         LDKCOption_FilterZ_Some_class =
10073                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
10074         CHECK(LDKCOption_FilterZ_Some_class != NULL);
10075         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
10076         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
10077         LDKCOption_FilterZ_None_class =
10078                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
10079         CHECK(LDKCOption_FilterZ_None_class != NULL);
10080         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
10081         CHECK(LDKCOption_FilterZ_None_meth != NULL);
10082 }
10083 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10084         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
10085         switch(obj->tag) {
10086                 case LDKCOption_FilterZ_Some: {
10087                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
10088                         *some_ret = obj->some;
10089                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
10090                         if ((*some_ret).free == LDKFilter_JCalls_free) {
10091                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10092                                 LDKFilter_JCalls_cloned(&(*some_ret));
10093                         }
10094                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (int64_t)some_ret);
10095                 }
10096                 case LDKCOption_FilterZ_None: {
10097                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
10098                 }
10099                 default: abort();
10100         }
10101 }
10102 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10103 CHECK(owner->result_ok);
10104         return &*owner->contents.result;
10105 }
10106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10107         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10108         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
10109         int64_t ret_ref = 0;
10110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10113         ret_ref = (uintptr_t)ret_var.inner & ~1;
10114         return ret_ref;
10115 }
10116
10117 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10118 CHECK(!owner->result_ok);
10119         return *owner->contents.err;
10120 }
10121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10122         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
10123         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
10124 }
10125
10126 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
10127         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
10128         for (size_t i = 0; i < ret.datalen; i++) {
10129                 ret.data[i] = OutPoint_clone(&orig->data[i]);
10130         }
10131         return ret;
10132 }
10133 typedef struct LDKMessageSendEventsProvider_JCalls {
10134         atomic_size_t refcnt;
10135         JavaVM *vm;
10136         jweak o;
10137         jmethodID get_and_clear_pending_msg_events_meth;
10138 } LDKMessageSendEventsProvider_JCalls;
10139 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
10140         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10141         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10142                 JNIEnv *env;
10143                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10144                 if (get_jenv_res == JNI_EDETACHED) {
10145                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10146                 } else {
10147                         DO_ASSERT(get_jenv_res == JNI_OK);
10148                 }
10149                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10150                 if (get_jenv_res == JNI_EDETACHED) {
10151                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10152                 }
10153                 FREE(j_calls);
10154         }
10155 }
10156 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
10157         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10158         JNIEnv *env;
10159         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10160         if (get_jenv_res == JNI_EDETACHED) {
10161                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10162         } else {
10163                 DO_ASSERT(get_jenv_res == JNI_OK);
10164         }
10165         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10166         CHECK(obj != NULL);
10167         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
10168         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10169                 (*env)->ExceptionDescribe(env);
10170                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
10171         }
10172         LDKCVec_MessageSendEventZ ret_constr;
10173         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10174         if (ret_constr.datalen > 0)
10175                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10176         else
10177                 ret_constr.data = NULL;
10178         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10179         for (size_t s = 0; s < ret_constr.datalen; s++) {
10180                 int64_t ret_conv_18 = ret_vals[s];
10181                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
10182                 CHECK_ACCESS(ret_conv_18_ptr);
10183                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
10184                 FREE((void*)ret_conv_18);
10185                 ret_constr.data[s] = ret_conv_18_conv;
10186         }
10187         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10188         if (get_jenv_res == JNI_EDETACHED) {
10189                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10190         }
10191         return ret_constr;
10192 }
10193 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10194         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10195         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10196 }
10197 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10198         jclass c = (*env)->GetObjectClass(env, o);
10199         CHECK(c != NULL);
10200         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10201         atomic_init(&calls->refcnt, 1);
10202         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10203         calls->o = (*env)->NewWeakGlobalRef(env, o);
10204         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10205         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10206
10207         LDKMessageSendEventsProvider ret = {
10208                 .this_arg = (void*) calls,
10209                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10210                 .free = LDKMessageSendEventsProvider_JCalls_free,
10211         };
10212         return ret;
10213 }
10214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10215         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10216         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10217         return (uint64_t)res_ptr;
10218 }
10219 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10220         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10221         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10222         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10223         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10224         int64_tArray ret_arr = NULL;
10225         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10226         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10227         for (size_t s = 0; s < ret_var.datalen; s++) {
10228                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10229                 *ret_conv_18_copy = ret_var.data[s];
10230                 int64_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
10231                 ret_arr_ptr[s] = ret_conv_18_ref;
10232         }
10233         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10234         FREE(ret_var.data);
10235         return ret_arr;
10236 }
10237
10238 typedef struct LDKEventHandler_JCalls {
10239         atomic_size_t refcnt;
10240         JavaVM *vm;
10241         jweak o;
10242         jmethodID handle_event_meth;
10243 } LDKEventHandler_JCalls;
10244 static void LDKEventHandler_JCalls_free(void* this_arg) {
10245         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10246         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10247                 JNIEnv *env;
10248                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10249                 if (get_jenv_res == JNI_EDETACHED) {
10250                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10251                 } else {
10252                         DO_ASSERT(get_jenv_res == JNI_OK);
10253                 }
10254                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10255                 if (get_jenv_res == JNI_EDETACHED) {
10256                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10257                 }
10258                 FREE(j_calls);
10259         }
10260 }
10261 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10262         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10263         JNIEnv *env;
10264         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10265         if (get_jenv_res == JNI_EDETACHED) {
10266                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10267         } else {
10268                 DO_ASSERT(get_jenv_res == JNI_OK);
10269         }
10270         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10271         *ret_event = Event_clone(event);
10272         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10273         CHECK(obj != NULL);
10274         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (int64_t)ret_event);
10275         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10276                 (*env)->ExceptionDescribe(env);
10277                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10278         }
10279         if (get_jenv_res == JNI_EDETACHED) {
10280                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10281         }
10282 }
10283 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10284         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10285         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10286 }
10287 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10288         jclass c = (*env)->GetObjectClass(env, o);
10289         CHECK(c != NULL);
10290         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10291         atomic_init(&calls->refcnt, 1);
10292         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10293         calls->o = (*env)->NewWeakGlobalRef(env, o);
10294         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10295         CHECK(calls->handle_event_meth != NULL);
10296
10297         LDKEventHandler ret = {
10298                 .this_arg = (void*) calls,
10299                 .handle_event = handle_event_LDKEventHandler_jcall,
10300                 .free = LDKEventHandler_JCalls_free,
10301         };
10302         return ret;
10303 }
10304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10305         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10306         *res_ptr = LDKEventHandler_init(env, clz, o);
10307         return (uint64_t)res_ptr;
10308 }
10309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10310         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10311         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10312         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10313         LDKEvent* event_conv = (LDKEvent*)event;
10314         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10315 }
10316
10317 typedef struct LDKEventsProvider_JCalls {
10318         atomic_size_t refcnt;
10319         JavaVM *vm;
10320         jweak o;
10321         jmethodID process_pending_events_meth;
10322 } LDKEventsProvider_JCalls;
10323 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10324         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10325         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10326                 JNIEnv *env;
10327                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10328                 if (get_jenv_res == JNI_EDETACHED) {
10329                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10330                 } else {
10331                         DO_ASSERT(get_jenv_res == JNI_OK);
10332                 }
10333                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10334                 if (get_jenv_res == JNI_EDETACHED) {
10335                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10336                 }
10337                 FREE(j_calls);
10338         }
10339 }
10340 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10341         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10342         JNIEnv *env;
10343         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10344         if (get_jenv_res == JNI_EDETACHED) {
10345                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10346         } else {
10347                 DO_ASSERT(get_jenv_res == JNI_OK);
10348         }
10349         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10350         *handler_ret = handler;
10351         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10352         CHECK(obj != NULL);
10353         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (int64_t)handler_ret);
10354         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10355                 (*env)->ExceptionDescribe(env);
10356                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10357         }
10358         if (get_jenv_res == JNI_EDETACHED) {
10359                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10360         }
10361 }
10362 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10363         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10364         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10365 }
10366 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10367         jclass c = (*env)->GetObjectClass(env, o);
10368         CHECK(c != NULL);
10369         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10370         atomic_init(&calls->refcnt, 1);
10371         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10372         calls->o = (*env)->NewWeakGlobalRef(env, o);
10373         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10374         CHECK(calls->process_pending_events_meth != NULL);
10375
10376         LDKEventsProvider ret = {
10377                 .this_arg = (void*) calls,
10378                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10379                 .free = LDKEventsProvider_JCalls_free,
10380         };
10381         return ret;
10382 }
10383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10384         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10385         *res_ptr = LDKEventsProvider_init(env, clz, o);
10386         return (uint64_t)res_ptr;
10387 }
10388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10389         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10390         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10391         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10392         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
10393         CHECK_ACCESS(handler_ptr);
10394         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10395         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10396                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10397                 LDKEventHandler_JCalls_cloned(&handler_conv);
10398         }
10399         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10400 }
10401
10402 typedef struct LDKScore_JCalls {
10403         atomic_size_t refcnt;
10404         JavaVM *vm;
10405         jweak o;
10406         jmethodID channel_penalty_msat_meth;
10407         jmethodID payment_path_failed_meth;
10408         jmethodID payment_path_successful_meth;
10409         jmethodID write_meth;
10410 } LDKScore_JCalls;
10411 static void LDKScore_JCalls_free(void* this_arg) {
10412         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10413         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10414                 JNIEnv *env;
10415                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10416                 if (get_jenv_res == JNI_EDETACHED) {
10417                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10418                 } else {
10419                         DO_ASSERT(get_jenv_res == JNI_OK);
10420                 }
10421                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10422                 if (get_jenv_res == JNI_EDETACHED) {
10423                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10424                 }
10425                 FREE(j_calls);
10426         }
10427 }
10428 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
10429         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10430         JNIEnv *env;
10431         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10432         if (get_jenv_res == JNI_EDETACHED) {
10433                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10434         } else {
10435                 DO_ASSERT(get_jenv_res == JNI_OK);
10436         }
10437         int64_t short_channel_id_conv = short_channel_id;
10438         LDKNodeId source_var = *source;
10439         int64_t source_ref = 0;
10440         source_var = NodeId_clone(&source_var);
10441         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10442         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10443         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
10444         source_ref = (uintptr_t)source_var.inner;
10445         if (source_var.is_owned) {
10446                 source_ref |= 1;
10447         }
10448         LDKNodeId target_var = *target;
10449         int64_t target_ref = 0;
10450         target_var = NodeId_clone(&target_var);
10451         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10452         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10453         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
10454         target_ref = (uintptr_t)target_var.inner;
10455         if (target_var.is_owned) {
10456                 target_ref |= 1;
10457         }
10458         LDKChannelUsage usage_var = usage;
10459         int64_t usage_ref = 0;
10460         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10461         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10462         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
10463         usage_ref = (uintptr_t)usage_var.inner;
10464         if (usage_var.is_owned) {
10465                 usage_ref |= 1;
10466         }
10467         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10468         CHECK(obj != NULL);
10469         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
10470         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10471                 (*env)->ExceptionDescribe(env);
10472                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10473         }
10474         if (get_jenv_res == JNI_EDETACHED) {
10475                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10476         }
10477         return ret;
10478 }
10479 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10480         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10481         JNIEnv *env;
10482         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10483         if (get_jenv_res == JNI_EDETACHED) {
10484                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10485         } else {
10486                 DO_ASSERT(get_jenv_res == JNI_OK);
10487         }
10488         LDKCVec_RouteHopZ path_var = path;
10489         int64_tArray path_arr = NULL;
10490         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10491         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10492         for (size_t k = 0; k < path_var.datalen; k++) {
10493                 LDKRouteHop path_conv_10_var = path_var.data[k];
10494                 int64_t path_conv_10_ref = 0;
10495                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10496                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10497                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10498                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10499                 if (path_conv_10_var.is_owned) {
10500                         path_conv_10_ref |= 1;
10501                 }
10502                 path_arr_ptr[k] = path_conv_10_ref;
10503         }
10504         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10505         FREE(path_var.data);
10506         int64_t short_channel_id_conv = short_channel_id;
10507         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10508         CHECK(obj != NULL);
10509         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
10510         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10511                 (*env)->ExceptionDescribe(env);
10512                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
10513         }
10514         if (get_jenv_res == JNI_EDETACHED) {
10515                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10516         }
10517 }
10518 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10519         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10520         JNIEnv *env;
10521         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10522         if (get_jenv_res == JNI_EDETACHED) {
10523                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10524         } else {
10525                 DO_ASSERT(get_jenv_res == JNI_OK);
10526         }
10527         LDKCVec_RouteHopZ path_var = path;
10528         int64_tArray path_arr = NULL;
10529         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10530         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10531         for (size_t k = 0; k < path_var.datalen; k++) {
10532                 LDKRouteHop path_conv_10_var = path_var.data[k];
10533                 int64_t path_conv_10_ref = 0;
10534                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10535                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10536                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10537                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10538                 if (path_conv_10_var.is_owned) {
10539                         path_conv_10_ref |= 1;
10540                 }
10541                 path_arr_ptr[k] = path_conv_10_ref;
10542         }
10543         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10544         FREE(path_var.data);
10545         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10546         CHECK(obj != NULL);
10547         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
10548         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10549                 (*env)->ExceptionDescribe(env);
10550                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
10551         }
10552         if (get_jenv_res == JNI_EDETACHED) {
10553                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10554         }
10555 }
10556 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10557         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10558         JNIEnv *env;
10559         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10560         if (get_jenv_res == JNI_EDETACHED) {
10561                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10562         } else {
10563                 DO_ASSERT(get_jenv_res == JNI_OK);
10564         }
10565         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10566         CHECK(obj != NULL);
10567         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
10568         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10569                 (*env)->ExceptionDescribe(env);
10570                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
10571         }
10572         LDKCVec_u8Z ret_ref;
10573         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
10574         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10575         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
10576         if (get_jenv_res == JNI_EDETACHED) {
10577                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10578         }
10579         return ret_ref;
10580 }
10581 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10582         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10583         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10584 }
10585 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10586         jclass c = (*env)->GetObjectClass(env, o);
10587         CHECK(c != NULL);
10588         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10589         atomic_init(&calls->refcnt, 1);
10590         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10591         calls->o = (*env)->NewWeakGlobalRef(env, o);
10592         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
10593         CHECK(calls->channel_penalty_msat_meth != NULL);
10594         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
10595         CHECK(calls->payment_path_failed_meth != NULL);
10596         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
10597         CHECK(calls->payment_path_successful_meth != NULL);
10598         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
10599         CHECK(calls->write_meth != NULL);
10600
10601         LDKScore ret = {
10602                 .this_arg = (void*) calls,
10603                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10604                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10605                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
10606                 .write = write_LDKScore_jcall,
10607                 .free = LDKScore_JCalls_free,
10608         };
10609         return ret;
10610 }
10611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10612         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10613         *res_ptr = LDKScore_init(env, clz, o);
10614         return (uint64_t)res_ptr;
10615 }
10616 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) {
10617         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10618         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10619         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10620         LDKNodeId source_conv;
10621         source_conv.inner = (void*)(source & (~1));
10622         source_conv.is_owned = false;
10623         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10624         LDKNodeId target_conv;
10625         target_conv.inner = (void*)(target & (~1));
10626         target_conv.is_owned = false;
10627         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10628         LDKChannelUsage usage_conv;
10629         usage_conv.inner = (void*)(usage & (~1));
10630         usage_conv.is_owned = (usage & 1) || (usage == 0);
10631         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
10632         usage_conv = ChannelUsage_clone(&usage_conv);
10633         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
10634         return ret_conv;
10635 }
10636
10637 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) {
10638         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10639         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10640         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10641         LDKCVec_RouteHopZ path_constr;
10642         path_constr.datalen = (*env)->GetArrayLength(env, path);
10643         if (path_constr.datalen > 0)
10644                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10645         else
10646                 path_constr.data = NULL;
10647         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10648         for (size_t k = 0; k < path_constr.datalen; k++) {
10649                 int64_t path_conv_10 = path_vals[k];
10650                 LDKRouteHop path_conv_10_conv;
10651                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10652                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10653                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10654                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10655                 path_constr.data[k] = path_conv_10_conv;
10656         }
10657         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10658         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10659 }
10660
10661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
10662         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10663         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10664         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10665         LDKCVec_RouteHopZ path_constr;
10666         path_constr.datalen = (*env)->GetArrayLength(env, path);
10667         if (path_constr.datalen > 0)
10668                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10669         else
10670                 path_constr.data = NULL;
10671         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10672         for (size_t k = 0; k < path_constr.datalen; k++) {
10673                 int64_t path_conv_10 = path_vals[k];
10674                 LDKRouteHop path_conv_10_conv;
10675                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10676                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10677                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10678                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10679                 path_constr.data[k] = path_conv_10_conv;
10680         }
10681         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10682         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
10683 }
10684
10685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
10686         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10687         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10688         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10689         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
10690         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10691         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10692         CVec_u8Z_free(ret_var);
10693         return ret_arr;
10694 }
10695
10696 typedef struct LDKPersister_JCalls {
10697         atomic_size_t refcnt;
10698         JavaVM *vm;
10699         jweak o;
10700         jmethodID persist_manager_meth;
10701         jmethodID persist_graph_meth;
10702         jmethodID persist_scorer_meth;
10703 } LDKPersister_JCalls;
10704 static void LDKPersister_JCalls_free(void* this_arg) {
10705         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10706         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10707                 JNIEnv *env;
10708                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10709                 if (get_jenv_res == JNI_EDETACHED) {
10710                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10711                 } else {
10712                         DO_ASSERT(get_jenv_res == JNI_OK);
10713                 }
10714                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10715                 if (get_jenv_res == JNI_EDETACHED) {
10716                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10717                 }
10718                 FREE(j_calls);
10719         }
10720 }
10721 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10722         LDKPersister_JCalls *j_calls = (LDKPersister_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         LDKChannelManager channel_manager_var = *channel_manager;
10731         int64_t channel_manager_ref = 0;
10732         // WARNING: we may need a move here but no clone is available for LDKChannelManager
10733         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10734         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10735         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
10736         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
10737         if (channel_manager_var.is_owned) {
10738                 channel_manager_ref |= 1;
10739         }
10740         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10741         CHECK(obj != NULL);
10742         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
10743         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10744                 (*env)->ExceptionDescribe(env);
10745                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
10746         }
10747         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10748         CHECK_ACCESS(ret_ptr);
10749         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10750         FREE((void*)ret);
10751         if (get_jenv_res == JNI_EDETACHED) {
10752                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10753         }
10754         return ret_conv;
10755 }
10756 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
10757         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10758         JNIEnv *env;
10759         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10760         if (get_jenv_res == JNI_EDETACHED) {
10761                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10762         } else {
10763                 DO_ASSERT(get_jenv_res == JNI_OK);
10764         }
10765         LDKNetworkGraph network_graph_var = *network_graph;
10766         int64_t network_graph_ref = 0;
10767         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
10768         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10769         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10770         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
10771         network_graph_ref = (uintptr_t)network_graph_var.inner;
10772         if (network_graph_var.is_owned) {
10773                 network_graph_ref |= 1;
10774         }
10775         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10776         CHECK(obj != NULL);
10777         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
10778         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10779                 (*env)->ExceptionDescribe(env);
10780                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
10781         }
10782         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10783         CHECK_ACCESS(ret_ptr);
10784         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10785         FREE((void*)ret);
10786         if (get_jenv_res == JNI_EDETACHED) {
10787                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10788         }
10789         return ret_conv;
10790 }
10791 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
10792         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10793         JNIEnv *env;
10794         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10795         if (get_jenv_res == JNI_EDETACHED) {
10796                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10797         } else {
10798                 DO_ASSERT(get_jenv_res == JNI_OK);
10799         }
10800         LDKMultiThreadedLockableScore scorer_var = *scorer;
10801         int64_t scorer_ref = 0;
10802         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
10803         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10804         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10805         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
10806         scorer_ref = (uintptr_t)scorer_var.inner;
10807         if (scorer_var.is_owned) {
10808                 scorer_ref |= 1;
10809         }
10810         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10811         CHECK(obj != NULL);
10812         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, scorer_ref);
10813         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10814                 (*env)->ExceptionDescribe(env);
10815                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
10816         }
10817         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10818         CHECK_ACCESS(ret_ptr);
10819         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10820         FREE((void*)ret);
10821         if (get_jenv_res == JNI_EDETACHED) {
10822                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10823         }
10824         return ret_conv;
10825 }
10826 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
10827         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
10828         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10829 }
10830 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
10831         jclass c = (*env)->GetObjectClass(env, o);
10832         CHECK(c != NULL);
10833         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
10834         atomic_init(&calls->refcnt, 1);
10835         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10836         calls->o = (*env)->NewWeakGlobalRef(env, o);
10837         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
10838         CHECK(calls->persist_manager_meth != NULL);
10839         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
10840         CHECK(calls->persist_graph_meth != NULL);
10841         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
10842         CHECK(calls->persist_scorer_meth != NULL);
10843
10844         LDKPersister ret = {
10845                 .this_arg = (void*) calls,
10846                 .persist_manager = persist_manager_LDKPersister_jcall,
10847                 .persist_graph = persist_graph_LDKPersister_jcall,
10848                 .persist_scorer = persist_scorer_LDKPersister_jcall,
10849                 .free = LDKPersister_JCalls_free,
10850         };
10851         return ret;
10852 }
10853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
10854         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
10855         *res_ptr = LDKPersister_init(env, clz, o);
10856         return (uint64_t)res_ptr;
10857 }
10858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
10859         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10860         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10861         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10862         LDKChannelManager channel_manager_conv;
10863         channel_manager_conv.inner = (void*)(channel_manager & (~1));
10864         channel_manager_conv.is_owned = false;
10865         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
10866         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10867         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
10868         return (int64_t)ret_conv;
10869 }
10870
10871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
10872         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10873         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10874         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10875         LDKNetworkGraph network_graph_conv;
10876         network_graph_conv.inner = (void*)(network_graph & (~1));
10877         network_graph_conv.is_owned = false;
10878         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
10879         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10880         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
10881         return (int64_t)ret_conv;
10882 }
10883
10884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
10885         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10886         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10887         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10888         LDKMultiThreadedLockableScore scorer_conv;
10889         scorer_conv.inner = (void*)(scorer & (~1));
10890         scorer_conv.is_owned = false;
10891         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
10892         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10893         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
10894         return (int64_t)ret_conv;
10895 }
10896
10897 typedef struct LDKListen_JCalls {
10898         atomic_size_t refcnt;
10899         JavaVM *vm;
10900         jweak o;
10901         jmethodID filtered_block_connected_meth;
10902         jmethodID block_connected_meth;
10903         jmethodID block_disconnected_meth;
10904 } LDKListen_JCalls;
10905 static void LDKListen_JCalls_free(void* this_arg) {
10906         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10907         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10908                 JNIEnv *env;
10909                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10910                 if (get_jenv_res == JNI_EDETACHED) {
10911                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10912                 } else {
10913                         DO_ASSERT(get_jenv_res == JNI_OK);
10914                 }
10915                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10916                 if (get_jenv_res == JNI_EDETACHED) {
10917                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10918                 }
10919                 FREE(j_calls);
10920         }
10921 }
10922 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
10923         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10924         JNIEnv *env;
10925         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10926         if (get_jenv_res == JNI_EDETACHED) {
10927                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10928         } else {
10929                 DO_ASSERT(get_jenv_res == JNI_OK);
10930         }
10931         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10932         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10933         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
10934         int64_tArray txdata_arr = NULL;
10935         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
10936         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
10937         for (size_t c = 0; c < txdata_var.datalen; c++) {
10938                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10939                 *txdata_conv_28_conv = txdata_var.data[c];
10940                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
10941         }
10942         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
10943         FREE(txdata_var.data);
10944         int32_t height_conv = height;
10945         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10946         CHECK(obj != NULL);
10947         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
10948         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10949                 (*env)->ExceptionDescribe(env);
10950                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
10951         }
10952         if (get_jenv_res == JNI_EDETACHED) {
10953                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10954         }
10955 }
10956 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
10957         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10958         JNIEnv *env;
10959         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10960         if (get_jenv_res == JNI_EDETACHED) {
10961                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10962         } else {
10963                 DO_ASSERT(get_jenv_res == JNI_OK);
10964         }
10965         LDKu8slice block_var = block;
10966         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
10967         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
10968         int32_t height_conv = height;
10969         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10970         CHECK(obj != NULL);
10971         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
10972         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10973                 (*env)->ExceptionDescribe(env);
10974                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
10975         }
10976         if (get_jenv_res == JNI_EDETACHED) {
10977                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10978         }
10979 }
10980 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10981         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10982         JNIEnv *env;
10983         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10984         if (get_jenv_res == JNI_EDETACHED) {
10985                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10986         } else {
10987                 DO_ASSERT(get_jenv_res == JNI_OK);
10988         }
10989         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10990         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10991         int32_t height_conv = height;
10992         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10993         CHECK(obj != NULL);
10994         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
10995         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10996                 (*env)->ExceptionDescribe(env);
10997                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
10998         }
10999         if (get_jenv_res == JNI_EDETACHED) {
11000                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11001         }
11002 }
11003 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
11004         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
11005         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11006 }
11007 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
11008         jclass c = (*env)->GetObjectClass(env, o);
11009         CHECK(c != NULL);
11010         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
11011         atomic_init(&calls->refcnt, 1);
11012         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11013         calls->o = (*env)->NewWeakGlobalRef(env, o);
11014         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
11015         CHECK(calls->filtered_block_connected_meth != NULL);
11016         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
11017         CHECK(calls->block_connected_meth != NULL);
11018         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
11019         CHECK(calls->block_disconnected_meth != NULL);
11020
11021         LDKListen ret = {
11022                 .this_arg = (void*) calls,
11023                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
11024                 .block_connected = block_connected_LDKListen_jcall,
11025                 .block_disconnected = block_disconnected_LDKListen_jcall,
11026                 .free = LDKListen_JCalls_free,
11027         };
11028         return ret;
11029 }
11030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
11031         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
11032         *res_ptr = LDKListen_init(env, clz, o);
11033         return (uint64_t)res_ptr;
11034 }
11035 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) {
11036         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11037         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11038         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11039         unsigned char header_arr[80];
11040         CHECK((*env)->GetArrayLength(env, header) == 80);
11041         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11042         unsigned char (*header_ref)[80] = &header_arr;
11043         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11044         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11045         if (txdata_constr.datalen > 0)
11046                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11047         else
11048                 txdata_constr.data = NULL;
11049         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11050         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11051                 int64_t txdata_conv_28 = txdata_vals[c];
11052                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
11053                 CHECK_ACCESS(txdata_conv_28_ptr);
11054                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11055                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
11056                 txdata_constr.data[c] = txdata_conv_28_conv;
11057         }
11058         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11059         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11060 }
11061
11062 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) {
11063         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11064         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11065         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11066         LDKu8slice block_ref;
11067         block_ref.datalen = (*env)->GetArrayLength(env, block);
11068         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
11069         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
11070         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
11071 }
11072
11073 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) {
11074         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11075         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11076         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11077         unsigned char header_arr[80];
11078         CHECK((*env)->GetArrayLength(env, header) == 80);
11079         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11080         unsigned char (*header_ref)[80] = &header_arr;
11081         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
11082 }
11083
11084 typedef struct LDKConfirm_JCalls {
11085         atomic_size_t refcnt;
11086         JavaVM *vm;
11087         jweak o;
11088         jmethodID transactions_confirmed_meth;
11089         jmethodID transaction_unconfirmed_meth;
11090         jmethodID best_block_updated_meth;
11091         jmethodID get_relevant_txids_meth;
11092 } LDKConfirm_JCalls;
11093 static void LDKConfirm_JCalls_free(void* this_arg) {
11094         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11095         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11096                 JNIEnv *env;
11097                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11098                 if (get_jenv_res == JNI_EDETACHED) {
11099                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11100                 } else {
11101                         DO_ASSERT(get_jenv_res == JNI_OK);
11102                 }
11103                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11104                 if (get_jenv_res == JNI_EDETACHED) {
11105                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11106                 }
11107                 FREE(j_calls);
11108         }
11109 }
11110 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11111         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11112         JNIEnv *env;
11113         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11114         if (get_jenv_res == JNI_EDETACHED) {
11115                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11116         } else {
11117                 DO_ASSERT(get_jenv_res == JNI_OK);
11118         }
11119         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11120         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11121         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11122         int64_tArray txdata_arr = NULL;
11123         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11124         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11125         for (size_t c = 0; c < txdata_var.datalen; c++) {
11126                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11127                 *txdata_conv_28_conv = txdata_var.data[c];
11128                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
11129         }
11130         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11131         FREE(txdata_var.data);
11132         int32_t height_conv = height;
11133         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11134         CHECK(obj != NULL);
11135         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
11136         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11137                 (*env)->ExceptionDescribe(env);
11138                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
11139         }
11140         if (get_jenv_res == JNI_EDETACHED) {
11141                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11142         }
11143 }
11144 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
11145         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11146         JNIEnv *env;
11147         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11148         if (get_jenv_res == JNI_EDETACHED) {
11149                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11150         } else {
11151                 DO_ASSERT(get_jenv_res == JNI_OK);
11152         }
11153         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11154         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11155         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11156         CHECK(obj != NULL);
11157         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
11158         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11159                 (*env)->ExceptionDescribe(env);
11160                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
11161         }
11162         if (get_jenv_res == JNI_EDETACHED) {
11163                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11164         }
11165 }
11166 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11167         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11168         JNIEnv *env;
11169         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11170         if (get_jenv_res == JNI_EDETACHED) {
11171                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11172         } else {
11173                 DO_ASSERT(get_jenv_res == JNI_OK);
11174         }
11175         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11176         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11177         int32_t height_conv = height;
11178         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11179         CHECK(obj != NULL);
11180         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
11181         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11182                 (*env)->ExceptionDescribe(env);
11183                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
11184         }
11185         if (get_jenv_res == JNI_EDETACHED) {
11186                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11187         }
11188 }
11189 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
11190         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11191         JNIEnv *env;
11192         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11193         if (get_jenv_res == JNI_EDETACHED) {
11194                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11195         } else {
11196                 DO_ASSERT(get_jenv_res == JNI_OK);
11197         }
11198         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11199         CHECK(obj != NULL);
11200         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
11201         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11202                 (*env)->ExceptionDescribe(env);
11203                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
11204         }
11205         LDKCVec_TxidZ ret_constr;
11206         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11207         if (ret_constr.datalen > 0)
11208                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11209         else
11210                 ret_constr.data = NULL;
11211         for (size_t i = 0; i < ret_constr.datalen; i++) {
11212                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
11213                 LDKThirtyTwoBytes ret_conv_8_ref;
11214                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
11215                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
11216                 ret_constr.data[i] = ret_conv_8_ref;
11217         }
11218         if (get_jenv_res == JNI_EDETACHED) {
11219                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11220         }
11221         return ret_constr;
11222 }
11223 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
11224         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
11225         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11226 }
11227 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
11228         jclass c = (*env)->GetObjectClass(env, o);
11229         CHECK(c != NULL);
11230         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
11231         atomic_init(&calls->refcnt, 1);
11232         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11233         calls->o = (*env)->NewWeakGlobalRef(env, o);
11234         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
11235         CHECK(calls->transactions_confirmed_meth != NULL);
11236         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
11237         CHECK(calls->transaction_unconfirmed_meth != NULL);
11238         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
11239         CHECK(calls->best_block_updated_meth != NULL);
11240         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
11241         CHECK(calls->get_relevant_txids_meth != NULL);
11242
11243         LDKConfirm ret = {
11244                 .this_arg = (void*) calls,
11245                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
11246                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
11247                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
11248                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
11249                 .free = LDKConfirm_JCalls_free,
11250         };
11251         return ret;
11252 }
11253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
11254         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11255         *res_ptr = LDKConfirm_init(env, clz, o);
11256         return (uint64_t)res_ptr;
11257 }
11258 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) {
11259         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11260         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11261         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11262         unsigned char header_arr[80];
11263         CHECK((*env)->GetArrayLength(env, header) == 80);
11264         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11265         unsigned char (*header_ref)[80] = &header_arr;
11266         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11267         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11268         if (txdata_constr.datalen > 0)
11269                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11270         else
11271                 txdata_constr.data = NULL;
11272         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11273         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11274                 int64_t txdata_conv_28 = txdata_vals[c];
11275                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
11276                 CHECK_ACCESS(txdata_conv_28_ptr);
11277                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11278                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
11279                 txdata_constr.data[c] = txdata_conv_28_conv;
11280         }
11281         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11282         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11283 }
11284
11285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11286         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11287         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11288         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11289         unsigned char txid_arr[32];
11290         CHECK((*env)->GetArrayLength(env, txid) == 32);
11291         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11292         unsigned char (*txid_ref)[32] = &txid_arr;
11293         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
11294 }
11295
11296 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) {
11297         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11298         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11299         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11300         unsigned char header_arr[80];
11301         CHECK((*env)->GetArrayLength(env, header) == 80);
11302         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11303         unsigned char (*header_ref)[80] = &header_arr;
11304         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
11305 }
11306
11307 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11308         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11309         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11310         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11311         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
11312         jobjectArray ret_arr = NULL;
11313         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11314         ;
11315         for (size_t i = 0; i < ret_var.datalen; i++) {
11316                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11317                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11318                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11319         }
11320         
11321         FREE(ret_var.data);
11322         return ret_arr;
11323 }
11324
11325 typedef struct LDKPersist_JCalls {
11326         atomic_size_t refcnt;
11327         JavaVM *vm;
11328         jweak o;
11329         jmethodID persist_new_channel_meth;
11330         jmethodID update_persisted_channel_meth;
11331 } LDKPersist_JCalls;
11332 static void LDKPersist_JCalls_free(void* this_arg) {
11333         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11334         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11335                 JNIEnv *env;
11336                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11337                 if (get_jenv_res == JNI_EDETACHED) {
11338                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11339                 } else {
11340                         DO_ASSERT(get_jenv_res == JNI_OK);
11341                 }
11342                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11343                 if (get_jenv_res == JNI_EDETACHED) {
11344                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11345                 }
11346                 FREE(j_calls);
11347         }
11348 }
11349 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11350         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11351         JNIEnv *env;
11352         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11353         if (get_jenv_res == JNI_EDETACHED) {
11354                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11355         } else {
11356                 DO_ASSERT(get_jenv_res == JNI_OK);
11357         }
11358         LDKOutPoint channel_id_var = channel_id;
11359         int64_t channel_id_ref = 0;
11360         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11361         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11362         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11363         channel_id_ref = (uintptr_t)channel_id_var.inner;
11364         if (channel_id_var.is_owned) {
11365                 channel_id_ref |= 1;
11366         }
11367         LDKChannelMonitor data_var = *data;
11368         int64_t data_ref = 0;
11369         data_var = ChannelMonitor_clone(&data_var);
11370         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11371         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11372         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11373         data_ref = (uintptr_t)data_var.inner;
11374         if (data_var.is_owned) {
11375                 data_ref |= 1;
11376         }
11377         LDKMonitorUpdateId update_id_var = update_id;
11378         int64_t update_id_ref = 0;
11379         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11380         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11381         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11382         update_id_ref = (uintptr_t)update_id_var.inner;
11383         if (update_id_var.is_owned) {
11384                 update_id_ref |= 1;
11385         }
11386         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11387         CHECK(obj != NULL);
11388         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
11389         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11390                 (*env)->ExceptionDescribe(env);
11391                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
11392         }
11393         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11394         CHECK_ACCESS(ret_ptr);
11395         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11396         FREE((void*)ret);
11397         if (get_jenv_res == JNI_EDETACHED) {
11398                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11399         }
11400         return ret_conv;
11401 }
11402 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11403         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11404         JNIEnv *env;
11405         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11406         if (get_jenv_res == JNI_EDETACHED) {
11407                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11408         } else {
11409                 DO_ASSERT(get_jenv_res == JNI_OK);
11410         }
11411         LDKOutPoint channel_id_var = channel_id;
11412         int64_t channel_id_ref = 0;
11413         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11414         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11415         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11416         channel_id_ref = (uintptr_t)channel_id_var.inner;
11417         if (channel_id_var.is_owned) {
11418                 channel_id_ref |= 1;
11419         }
11420         LDKChannelMonitorUpdate update_var = *update;
11421         int64_t update_ref = 0;
11422         if ((uintptr_t)update_var.inner > 4096) {
11423                 update_var = ChannelMonitorUpdate_clone(&update_var);
11424                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11425                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11426         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
11427                 update_ref = (uintptr_t)update_var.inner;
11428                 if (update_var.is_owned) {
11429                         update_ref |= 1;
11430                 }
11431         }
11432         LDKChannelMonitor data_var = *data;
11433         int64_t data_ref = 0;
11434         data_var = ChannelMonitor_clone(&data_var);
11435         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11436         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11437         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11438         data_ref = (uintptr_t)data_var.inner;
11439         if (data_var.is_owned) {
11440                 data_ref |= 1;
11441         }
11442         LDKMonitorUpdateId update_id_var = update_id;
11443         int64_t update_id_ref = 0;
11444         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11445         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11446         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11447         update_id_ref = (uintptr_t)update_id_var.inner;
11448         if (update_id_var.is_owned) {
11449                 update_id_ref |= 1;
11450         }
11451         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11452         CHECK(obj != NULL);
11453         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
11454         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11455                 (*env)->ExceptionDescribe(env);
11456                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
11457         }
11458         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11459         CHECK_ACCESS(ret_ptr);
11460         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11461         FREE((void*)ret);
11462         if (get_jenv_res == JNI_EDETACHED) {
11463                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11464         }
11465         return ret_conv;
11466 }
11467 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
11468         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
11469         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11470 }
11471 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
11472         jclass c = (*env)->GetObjectClass(env, o);
11473         CHECK(c != NULL);
11474         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
11475         atomic_init(&calls->refcnt, 1);
11476         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11477         calls->o = (*env)->NewWeakGlobalRef(env, o);
11478         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
11479         CHECK(calls->persist_new_channel_meth != NULL);
11480         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
11481         CHECK(calls->update_persisted_channel_meth != NULL);
11482
11483         LDKPersist ret = {
11484                 .this_arg = (void*) calls,
11485                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
11486                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
11487                 .free = LDKPersist_JCalls_free,
11488         };
11489         return ret;
11490 }
11491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
11492         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
11493         *res_ptr = LDKPersist_init(env, clz, o);
11494         return (uint64_t)res_ptr;
11495 }
11496 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) {
11497         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11498         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11499         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11500         LDKOutPoint channel_id_conv;
11501         channel_id_conv.inner = (void*)(channel_id & (~1));
11502         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11503         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11504         channel_id_conv = OutPoint_clone(&channel_id_conv);
11505         LDKChannelMonitor data_conv;
11506         data_conv.inner = (void*)(data & (~1));
11507         data_conv.is_owned = false;
11508         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11509         LDKMonitorUpdateId update_id_conv;
11510         update_id_conv.inner = (void*)(update_id & (~1));
11511         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11512         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11513         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11514         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11515         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
11516         return (int64_t)ret_conv;
11517 }
11518
11519 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) {
11520         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11521         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11522         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11523         LDKOutPoint channel_id_conv;
11524         channel_id_conv.inner = (void*)(channel_id & (~1));
11525         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
11526         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11527         channel_id_conv = OutPoint_clone(&channel_id_conv);
11528         LDKChannelMonitorUpdate update_conv;
11529         update_conv.inner = (void*)(update & (~1));
11530         update_conv.is_owned = false;
11531         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
11532         LDKChannelMonitor data_conv;
11533         data_conv.inner = (void*)(data & (~1));
11534         data_conv.is_owned = false;
11535         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11536         LDKMonitorUpdateId update_id_conv;
11537         update_id_conv.inner = (void*)(update_id & (~1));
11538         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
11539         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11540         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11541         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11542         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
11543         return (int64_t)ret_conv;
11544 }
11545
11546 typedef struct LDKChannelMessageHandler_JCalls {
11547         atomic_size_t refcnt;
11548         JavaVM *vm;
11549         jweak o;
11550         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11551         jmethodID handle_open_channel_meth;
11552         jmethodID handle_accept_channel_meth;
11553         jmethodID handle_funding_created_meth;
11554         jmethodID handle_funding_signed_meth;
11555         jmethodID handle_channel_ready_meth;
11556         jmethodID handle_shutdown_meth;
11557         jmethodID handle_closing_signed_meth;
11558         jmethodID handle_update_add_htlc_meth;
11559         jmethodID handle_update_fulfill_htlc_meth;
11560         jmethodID handle_update_fail_htlc_meth;
11561         jmethodID handle_update_fail_malformed_htlc_meth;
11562         jmethodID handle_commitment_signed_meth;
11563         jmethodID handle_revoke_and_ack_meth;
11564         jmethodID handle_update_fee_meth;
11565         jmethodID handle_announcement_signatures_meth;
11566         jmethodID peer_disconnected_meth;
11567         jmethodID peer_connected_meth;
11568         jmethodID handle_channel_reestablish_meth;
11569         jmethodID handle_channel_update_meth;
11570         jmethodID handle_error_meth;
11571 } LDKChannelMessageHandler_JCalls;
11572 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
11573         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11574         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11575                 JNIEnv *env;
11576                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11577                 if (get_jenv_res == JNI_EDETACHED) {
11578                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11579                 } else {
11580                         DO_ASSERT(get_jenv_res == JNI_OK);
11581                 }
11582                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11583                 if (get_jenv_res == JNI_EDETACHED) {
11584                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11585                 }
11586                 FREE(j_calls);
11587         }
11588 }
11589 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
11590         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11591         JNIEnv *env;
11592         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11593         if (get_jenv_res == JNI_EDETACHED) {
11594                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11595         } else {
11596                 DO_ASSERT(get_jenv_res == JNI_OK);
11597         }
11598         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11599         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11600         LDKInitFeatures their_features_var = their_features;
11601         int64_t their_features_ref = 0;
11602         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11603         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11604         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11605         their_features_ref = (uintptr_t)their_features_var.inner;
11606         if (their_features_var.is_owned) {
11607                 their_features_ref |= 1;
11608         }
11609         LDKOpenChannel msg_var = *msg;
11610         int64_t msg_ref = 0;
11611         msg_var = OpenChannel_clone(&msg_var);
11612         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11613         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11614         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11615         msg_ref = (uintptr_t)msg_var.inner;
11616         if (msg_var.is_owned) {
11617                 msg_ref |= 1;
11618         }
11619         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11620         CHECK(obj != NULL);
11621         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11622         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11623                 (*env)->ExceptionDescribe(env);
11624                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
11625         }
11626         if (get_jenv_res == JNI_EDETACHED) {
11627                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11628         }
11629 }
11630 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
11631         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11632         JNIEnv *env;
11633         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11634         if (get_jenv_res == JNI_EDETACHED) {
11635                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11636         } else {
11637                 DO_ASSERT(get_jenv_res == JNI_OK);
11638         }
11639         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11640         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11641         LDKInitFeatures their_features_var = their_features;
11642         int64_t their_features_ref = 0;
11643         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11644         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11645         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11646         their_features_ref = (uintptr_t)their_features_var.inner;
11647         if (their_features_var.is_owned) {
11648                 their_features_ref |= 1;
11649         }
11650         LDKAcceptChannel msg_var = *msg;
11651         int64_t msg_ref = 0;
11652         msg_var = AcceptChannel_clone(&msg_var);
11653         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11654         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11655         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11656         msg_ref = (uintptr_t)msg_var.inner;
11657         if (msg_var.is_owned) {
11658                 msg_ref |= 1;
11659         }
11660         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11661         CHECK(obj != NULL);
11662         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11663         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11664                 (*env)->ExceptionDescribe(env);
11665                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
11666         }
11667         if (get_jenv_res == JNI_EDETACHED) {
11668                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11669         }
11670 }
11671 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
11672         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11673         JNIEnv *env;
11674         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11675         if (get_jenv_res == JNI_EDETACHED) {
11676                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11677         } else {
11678                 DO_ASSERT(get_jenv_res == JNI_OK);
11679         }
11680         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11681         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11682         LDKFundingCreated msg_var = *msg;
11683         int64_t msg_ref = 0;
11684         msg_var = FundingCreated_clone(&msg_var);
11685         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11686         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11687         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11688         msg_ref = (uintptr_t)msg_var.inner;
11689         if (msg_var.is_owned) {
11690                 msg_ref |= 1;
11691         }
11692         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11693         CHECK(obj != NULL);
11694         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
11695         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11696                 (*env)->ExceptionDescribe(env);
11697                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
11698         }
11699         if (get_jenv_res == JNI_EDETACHED) {
11700                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11701         }
11702 }
11703 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
11704         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11705         JNIEnv *env;
11706         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11707         if (get_jenv_res == JNI_EDETACHED) {
11708                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11709         } else {
11710                 DO_ASSERT(get_jenv_res == JNI_OK);
11711         }
11712         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11713         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11714         LDKFundingSigned msg_var = *msg;
11715         int64_t msg_ref = 0;
11716         msg_var = FundingSigned_clone(&msg_var);
11717         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11718         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11719         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11720         msg_ref = (uintptr_t)msg_var.inner;
11721         if (msg_var.is_owned) {
11722                 msg_ref |= 1;
11723         }
11724         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11725         CHECK(obj != NULL);
11726         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
11727         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11728                 (*env)->ExceptionDescribe(env);
11729                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
11730         }
11731         if (get_jenv_res == JNI_EDETACHED) {
11732                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11733         }
11734 }
11735 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
11736         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11737         JNIEnv *env;
11738         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11739         if (get_jenv_res == JNI_EDETACHED) {
11740                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11741         } else {
11742                 DO_ASSERT(get_jenv_res == JNI_OK);
11743         }
11744         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11745         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11746         LDKChannelReady msg_var = *msg;
11747         int64_t msg_ref = 0;
11748         msg_var = ChannelReady_clone(&msg_var);
11749         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11750         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11751         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11752         msg_ref = (uintptr_t)msg_var.inner;
11753         if (msg_var.is_owned) {
11754                 msg_ref |= 1;
11755         }
11756         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11757         CHECK(obj != NULL);
11758         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
11759         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11760                 (*env)->ExceptionDescribe(env);
11761                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
11762         }
11763         if (get_jenv_res == JNI_EDETACHED) {
11764                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11765         }
11766 }
11767 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
11768         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11769         JNIEnv *env;
11770         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11771         if (get_jenv_res == JNI_EDETACHED) {
11772                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11773         } else {
11774                 DO_ASSERT(get_jenv_res == JNI_OK);
11775         }
11776         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11777         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11778         LDKInitFeatures their_features_var = *their_features;
11779         int64_t their_features_ref = 0;
11780         their_features_var = InitFeatures_clone(&their_features_var);
11781         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11782         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11783         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11784         their_features_ref = (uintptr_t)their_features_var.inner;
11785         if (their_features_var.is_owned) {
11786                 their_features_ref |= 1;
11787         }
11788         LDKShutdown msg_var = *msg;
11789         int64_t msg_ref = 0;
11790         msg_var = Shutdown_clone(&msg_var);
11791         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11792         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11793         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11794         msg_ref = (uintptr_t)msg_var.inner;
11795         if (msg_var.is_owned) {
11796                 msg_ref |= 1;
11797         }
11798         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11799         CHECK(obj != NULL);
11800         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
11801         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11802                 (*env)->ExceptionDescribe(env);
11803                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
11804         }
11805         if (get_jenv_res == JNI_EDETACHED) {
11806                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11807         }
11808 }
11809 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
11810         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11811         JNIEnv *env;
11812         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11813         if (get_jenv_res == JNI_EDETACHED) {
11814                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11815         } else {
11816                 DO_ASSERT(get_jenv_res == JNI_OK);
11817         }
11818         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11819         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11820         LDKClosingSigned msg_var = *msg;
11821         int64_t msg_ref = 0;
11822         msg_var = ClosingSigned_clone(&msg_var);
11823         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11824         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11825         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11826         msg_ref = (uintptr_t)msg_var.inner;
11827         if (msg_var.is_owned) {
11828                 msg_ref |= 1;
11829         }
11830         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11831         CHECK(obj != NULL);
11832         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
11833         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11834                 (*env)->ExceptionDescribe(env);
11835                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
11836         }
11837         if (get_jenv_res == JNI_EDETACHED) {
11838                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11839         }
11840 }
11841 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
11842         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11843         JNIEnv *env;
11844         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11845         if (get_jenv_res == JNI_EDETACHED) {
11846                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11847         } else {
11848                 DO_ASSERT(get_jenv_res == JNI_OK);
11849         }
11850         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11851         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11852         LDKUpdateAddHTLC msg_var = *msg;
11853         int64_t msg_ref = 0;
11854         msg_var = UpdateAddHTLC_clone(&msg_var);
11855         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11856         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11857         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11858         msg_ref = (uintptr_t)msg_var.inner;
11859         if (msg_var.is_owned) {
11860                 msg_ref |= 1;
11861         }
11862         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11863         CHECK(obj != NULL);
11864         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
11865         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11866                 (*env)->ExceptionDescribe(env);
11867                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
11868         }
11869         if (get_jenv_res == JNI_EDETACHED) {
11870                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11871         }
11872 }
11873 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
11874         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11875         JNIEnv *env;
11876         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11877         if (get_jenv_res == JNI_EDETACHED) {
11878                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11879         } else {
11880                 DO_ASSERT(get_jenv_res == JNI_OK);
11881         }
11882         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11883         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11884         LDKUpdateFulfillHTLC msg_var = *msg;
11885         int64_t msg_ref = 0;
11886         msg_var = UpdateFulfillHTLC_clone(&msg_var);
11887         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11888         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11889         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11890         msg_ref = (uintptr_t)msg_var.inner;
11891         if (msg_var.is_owned) {
11892                 msg_ref |= 1;
11893         }
11894         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11895         CHECK(obj != NULL);
11896         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
11897         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11898                 (*env)->ExceptionDescribe(env);
11899                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
11900         }
11901         if (get_jenv_res == JNI_EDETACHED) {
11902                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11903         }
11904 }
11905 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
11906         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11907         JNIEnv *env;
11908         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11909         if (get_jenv_res == JNI_EDETACHED) {
11910                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11911         } else {
11912                 DO_ASSERT(get_jenv_res == JNI_OK);
11913         }
11914         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11915         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11916         LDKUpdateFailHTLC msg_var = *msg;
11917         int64_t msg_ref = 0;
11918         msg_var = UpdateFailHTLC_clone(&msg_var);
11919         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11920         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11921         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11922         msg_ref = (uintptr_t)msg_var.inner;
11923         if (msg_var.is_owned) {
11924                 msg_ref |= 1;
11925         }
11926         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11927         CHECK(obj != NULL);
11928         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
11929         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11930                 (*env)->ExceptionDescribe(env);
11931                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
11932         }
11933         if (get_jenv_res == JNI_EDETACHED) {
11934                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11935         }
11936 }
11937 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
11938         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11939         JNIEnv *env;
11940         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11941         if (get_jenv_res == JNI_EDETACHED) {
11942                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11943         } else {
11944                 DO_ASSERT(get_jenv_res == JNI_OK);
11945         }
11946         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11947         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11948         LDKUpdateFailMalformedHTLC msg_var = *msg;
11949         int64_t msg_ref = 0;
11950         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
11951         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11952         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11953         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11954         msg_ref = (uintptr_t)msg_var.inner;
11955         if (msg_var.is_owned) {
11956                 msg_ref |= 1;
11957         }
11958         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11959         CHECK(obj != NULL);
11960         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
11961         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11962                 (*env)->ExceptionDescribe(env);
11963                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
11964         }
11965         if (get_jenv_res == JNI_EDETACHED) {
11966                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11967         }
11968 }
11969 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
11970         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11971         JNIEnv *env;
11972         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11973         if (get_jenv_res == JNI_EDETACHED) {
11974                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11975         } else {
11976                 DO_ASSERT(get_jenv_res == JNI_OK);
11977         }
11978         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11979         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11980         LDKCommitmentSigned msg_var = *msg;
11981         int64_t msg_ref = 0;
11982         msg_var = CommitmentSigned_clone(&msg_var);
11983         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11984         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11985         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11986         msg_ref = (uintptr_t)msg_var.inner;
11987         if (msg_var.is_owned) {
11988                 msg_ref |= 1;
11989         }
11990         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11991         CHECK(obj != NULL);
11992         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
11993         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11994                 (*env)->ExceptionDescribe(env);
11995                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
11996         }
11997         if (get_jenv_res == JNI_EDETACHED) {
11998                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11999         }
12000 }
12001 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
12002         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12003         JNIEnv *env;
12004         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12005         if (get_jenv_res == JNI_EDETACHED) {
12006                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12007         } else {
12008                 DO_ASSERT(get_jenv_res == JNI_OK);
12009         }
12010         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12011         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12012         LDKRevokeAndACK msg_var = *msg;
12013         int64_t msg_ref = 0;
12014         msg_var = RevokeAndACK_clone(&msg_var);
12015         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12016         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12017         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12018         msg_ref = (uintptr_t)msg_var.inner;
12019         if (msg_var.is_owned) {
12020                 msg_ref |= 1;
12021         }
12022         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12023         CHECK(obj != NULL);
12024         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
12025         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12026                 (*env)->ExceptionDescribe(env);
12027                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
12028         }
12029         if (get_jenv_res == JNI_EDETACHED) {
12030                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12031         }
12032 }
12033 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
12034         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12035         JNIEnv *env;
12036         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12037         if (get_jenv_res == JNI_EDETACHED) {
12038                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12039         } else {
12040                 DO_ASSERT(get_jenv_res == JNI_OK);
12041         }
12042         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12043         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12044         LDKUpdateFee msg_var = *msg;
12045         int64_t msg_ref = 0;
12046         msg_var = UpdateFee_clone(&msg_var);
12047         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12048         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12049         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12050         msg_ref = (uintptr_t)msg_var.inner;
12051         if (msg_var.is_owned) {
12052                 msg_ref |= 1;
12053         }
12054         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12055         CHECK(obj != NULL);
12056         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
12057         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12058                 (*env)->ExceptionDescribe(env);
12059                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
12060         }
12061         if (get_jenv_res == JNI_EDETACHED) {
12062                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12063         }
12064 }
12065 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
12066         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12067         JNIEnv *env;
12068         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12069         if (get_jenv_res == JNI_EDETACHED) {
12070                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12071         } else {
12072                 DO_ASSERT(get_jenv_res == JNI_OK);
12073         }
12074         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12075         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12076         LDKAnnouncementSignatures msg_var = *msg;
12077         int64_t msg_ref = 0;
12078         msg_var = AnnouncementSignatures_clone(&msg_var);
12079         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12080         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12081         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12082         msg_ref = (uintptr_t)msg_var.inner;
12083         if (msg_var.is_owned) {
12084                 msg_ref |= 1;
12085         }
12086         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12087         CHECK(obj != NULL);
12088         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
12089         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12090                 (*env)->ExceptionDescribe(env);
12091                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
12092         }
12093         if (get_jenv_res == JNI_EDETACHED) {
12094                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12095         }
12096 }
12097 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
12098         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12099         JNIEnv *env;
12100         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12101         if (get_jenv_res == JNI_EDETACHED) {
12102                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12103         } else {
12104                 DO_ASSERT(get_jenv_res == JNI_OK);
12105         }
12106         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12107         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12108         jboolean no_connection_possible_conv = no_connection_possible;
12109         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12110         CHECK(obj != NULL);
12111         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
12112         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12113                 (*env)->ExceptionDescribe(env);
12114                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
12115         }
12116         if (get_jenv_res == JNI_EDETACHED) {
12117                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12118         }
12119 }
12120 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
12121         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12122         JNIEnv *env;
12123         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12124         if (get_jenv_res == JNI_EDETACHED) {
12125                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12126         } else {
12127                 DO_ASSERT(get_jenv_res == JNI_OK);
12128         }
12129         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12130         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12131         LDKInit msg_var = *msg;
12132         int64_t msg_ref = 0;
12133         msg_var = Init_clone(&msg_var);
12134         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12135         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12136         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12137         msg_ref = (uintptr_t)msg_var.inner;
12138         if (msg_var.is_owned) {
12139                 msg_ref |= 1;
12140         }
12141         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12142         CHECK(obj != NULL);
12143         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
12144         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12145                 (*env)->ExceptionDescribe(env);
12146                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
12147         }
12148         if (get_jenv_res == JNI_EDETACHED) {
12149                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12150         }
12151 }
12152 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
12153         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12154         JNIEnv *env;
12155         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12156         if (get_jenv_res == JNI_EDETACHED) {
12157                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12158         } else {
12159                 DO_ASSERT(get_jenv_res == JNI_OK);
12160         }
12161         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12162         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12163         LDKChannelReestablish msg_var = *msg;
12164         int64_t msg_ref = 0;
12165         msg_var = ChannelReestablish_clone(&msg_var);
12166         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12167         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12168         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12169         msg_ref = (uintptr_t)msg_var.inner;
12170         if (msg_var.is_owned) {
12171                 msg_ref |= 1;
12172         }
12173         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12174         CHECK(obj != NULL);
12175         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
12176         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12177                 (*env)->ExceptionDescribe(env);
12178                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
12179         }
12180         if (get_jenv_res == JNI_EDETACHED) {
12181                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12182         }
12183 }
12184 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
12185         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12186         JNIEnv *env;
12187         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12188         if (get_jenv_res == JNI_EDETACHED) {
12189                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12190         } else {
12191                 DO_ASSERT(get_jenv_res == JNI_OK);
12192         }
12193         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12194         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12195         LDKChannelUpdate msg_var = *msg;
12196         int64_t msg_ref = 0;
12197         msg_var = ChannelUpdate_clone(&msg_var);
12198         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12199         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12200         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12201         msg_ref = (uintptr_t)msg_var.inner;
12202         if (msg_var.is_owned) {
12203                 msg_ref |= 1;
12204         }
12205         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12206         CHECK(obj != NULL);
12207         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
12208         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12209                 (*env)->ExceptionDescribe(env);
12210                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
12211         }
12212         if (get_jenv_res == JNI_EDETACHED) {
12213                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12214         }
12215 }
12216 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
12217         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12218         JNIEnv *env;
12219         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12220         if (get_jenv_res == JNI_EDETACHED) {
12221                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12222         } else {
12223                 DO_ASSERT(get_jenv_res == JNI_OK);
12224         }
12225         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12226         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12227         LDKErrorMessage msg_var = *msg;
12228         int64_t msg_ref = 0;
12229         msg_var = ErrorMessage_clone(&msg_var);
12230         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12231         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12232         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12233         msg_ref = (uintptr_t)msg_var.inner;
12234         if (msg_var.is_owned) {
12235                 msg_ref |= 1;
12236         }
12237         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12238         CHECK(obj != NULL);
12239         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
12240         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12241                 (*env)->ExceptionDescribe(env);
12242                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
12243         }
12244         if (get_jenv_res == JNI_EDETACHED) {
12245                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12246         }
12247 }
12248 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
12249         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
12250         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12251         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12252 }
12253 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12254         jclass c = (*env)->GetObjectClass(env, o);
12255         CHECK(c != NULL);
12256         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
12257         atomic_init(&calls->refcnt, 1);
12258         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12259         calls->o = (*env)->NewWeakGlobalRef(env, o);
12260         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
12261         CHECK(calls->handle_open_channel_meth != NULL);
12262         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
12263         CHECK(calls->handle_accept_channel_meth != NULL);
12264         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
12265         CHECK(calls->handle_funding_created_meth != NULL);
12266         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
12267         CHECK(calls->handle_funding_signed_meth != NULL);
12268         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
12269         CHECK(calls->handle_channel_ready_meth != NULL);
12270         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
12271         CHECK(calls->handle_shutdown_meth != NULL);
12272         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
12273         CHECK(calls->handle_closing_signed_meth != NULL);
12274         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
12275         CHECK(calls->handle_update_add_htlc_meth != NULL);
12276         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
12277         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
12278         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
12279         CHECK(calls->handle_update_fail_htlc_meth != NULL);
12280         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
12281         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
12282         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
12283         CHECK(calls->handle_commitment_signed_meth != NULL);
12284         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
12285         CHECK(calls->handle_revoke_and_ack_meth != NULL);
12286         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
12287         CHECK(calls->handle_update_fee_meth != NULL);
12288         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
12289         CHECK(calls->handle_announcement_signatures_meth != NULL);
12290         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
12291         CHECK(calls->peer_disconnected_meth != NULL);
12292         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12293         CHECK(calls->peer_connected_meth != NULL);
12294         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
12295         CHECK(calls->handle_channel_reestablish_meth != NULL);
12296         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
12297         CHECK(calls->handle_channel_update_meth != NULL);
12298         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
12299         CHECK(calls->handle_error_meth != NULL);
12300
12301         LDKChannelMessageHandler ret = {
12302                 .this_arg = (void*) calls,
12303                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
12304                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
12305                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
12306                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
12307                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
12308                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
12309                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
12310                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
12311                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
12312                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
12313                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
12314                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
12315                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
12316                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
12317                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
12318                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
12319                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
12320                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
12321                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
12322                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
12323                 .free = LDKChannelMessageHandler_JCalls_free,
12324                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12325         };
12326         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12327         return ret;
12328 }
12329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12330         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12331         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12332         return (uint64_t)res_ptr;
12333 }
12334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12335         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
12336         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
12337         DO_ASSERT((res_ptr & 1) == 0);
12338         return (int64_t)(res_ptr | 1);
12339 }
12340 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) {
12341         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12342         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12343         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12344         LDKPublicKey their_node_id_ref;
12345         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12346         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12347         LDKInitFeatures their_features_conv;
12348         their_features_conv.inner = (void*)(their_features & (~1));
12349         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12350         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12351         their_features_conv = InitFeatures_clone(&their_features_conv);
12352         LDKOpenChannel msg_conv;
12353         msg_conv.inner = (void*)(msg & (~1));
12354         msg_conv.is_owned = false;
12355         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12356         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12357 }
12358
12359 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) {
12360         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12361         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12362         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12363         LDKPublicKey their_node_id_ref;
12364         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12365         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12366         LDKInitFeatures their_features_conv;
12367         their_features_conv.inner = (void*)(their_features & (~1));
12368         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
12369         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12370         their_features_conv = InitFeatures_clone(&their_features_conv);
12371         LDKAcceptChannel msg_conv;
12372         msg_conv.inner = (void*)(msg & (~1));
12373         msg_conv.is_owned = false;
12374         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12375         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12376 }
12377
12378 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) {
12379         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12380         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12381         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12382         LDKPublicKey their_node_id_ref;
12383         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12384         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12385         LDKFundingCreated msg_conv;
12386         msg_conv.inner = (void*)(msg & (~1));
12387         msg_conv.is_owned = false;
12388         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12389         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12390 }
12391
12392 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) {
12393         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12394         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12395         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12396         LDKPublicKey their_node_id_ref;
12397         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12398         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12399         LDKFundingSigned msg_conv;
12400         msg_conv.inner = (void*)(msg & (~1));
12401         msg_conv.is_owned = false;
12402         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12403         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12404 }
12405
12406 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) {
12407         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12408         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12409         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12410         LDKPublicKey their_node_id_ref;
12411         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12412         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12413         LDKChannelReady msg_conv;
12414         msg_conv.inner = (void*)(msg & (~1));
12415         msg_conv.is_owned = false;
12416         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12417         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12418 }
12419
12420 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) {
12421         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12422         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12423         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12424         LDKPublicKey their_node_id_ref;
12425         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12426         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12427         LDKInitFeatures their_features_conv;
12428         their_features_conv.inner = (void*)(their_features & (~1));
12429         their_features_conv.is_owned = false;
12430         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12431         LDKShutdown msg_conv;
12432         msg_conv.inner = (void*)(msg & (~1));
12433         msg_conv.is_owned = false;
12434         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12435         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
12436 }
12437
12438 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) {
12439         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12440         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12441         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12442         LDKPublicKey their_node_id_ref;
12443         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12444         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12445         LDKClosingSigned msg_conv;
12446         msg_conv.inner = (void*)(msg & (~1));
12447         msg_conv.is_owned = false;
12448         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12449         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12450 }
12451
12452 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) {
12453         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12454         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12455         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12456         LDKPublicKey their_node_id_ref;
12457         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12458         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12459         LDKUpdateAddHTLC msg_conv;
12460         msg_conv.inner = (void*)(msg & (~1));
12461         msg_conv.is_owned = false;
12462         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12463         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12464 }
12465
12466 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) {
12467         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12468         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12469         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12470         LDKPublicKey their_node_id_ref;
12471         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12472         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12473         LDKUpdateFulfillHTLC msg_conv;
12474         msg_conv.inner = (void*)(msg & (~1));
12475         msg_conv.is_owned = false;
12476         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12477         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12478 }
12479
12480 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) {
12481         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12482         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12483         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12484         LDKPublicKey their_node_id_ref;
12485         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12486         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12487         LDKUpdateFailHTLC msg_conv;
12488         msg_conv.inner = (void*)(msg & (~1));
12489         msg_conv.is_owned = false;
12490         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12491         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12492 }
12493
12494 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) {
12495         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12496         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12497         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12498         LDKPublicKey their_node_id_ref;
12499         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12500         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12501         LDKUpdateFailMalformedHTLC msg_conv;
12502         msg_conv.inner = (void*)(msg & (~1));
12503         msg_conv.is_owned = false;
12504         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12505         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12506 }
12507
12508 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) {
12509         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12510         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12511         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12512         LDKPublicKey their_node_id_ref;
12513         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12514         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12515         LDKCommitmentSigned msg_conv;
12516         msg_conv.inner = (void*)(msg & (~1));
12517         msg_conv.is_owned = false;
12518         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12519         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12520 }
12521
12522 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) {
12523         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12524         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12525         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12526         LDKPublicKey their_node_id_ref;
12527         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12528         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12529         LDKRevokeAndACK msg_conv;
12530         msg_conv.inner = (void*)(msg & (~1));
12531         msg_conv.is_owned = false;
12532         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12533         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12534 }
12535
12536 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) {
12537         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12538         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12539         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12540         LDKPublicKey their_node_id_ref;
12541         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12542         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12543         LDKUpdateFee msg_conv;
12544         msg_conv.inner = (void*)(msg & (~1));
12545         msg_conv.is_owned = false;
12546         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12547         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12548 }
12549
12550 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) {
12551         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12552         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12553         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12554         LDKPublicKey their_node_id_ref;
12555         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12556         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12557         LDKAnnouncementSignatures msg_conv;
12558         msg_conv.inner = (void*)(msg & (~1));
12559         msg_conv.is_owned = false;
12560         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12561         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12562 }
12563
12564 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) {
12565         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12566         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12567         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12568         LDKPublicKey their_node_id_ref;
12569         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12570         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12571         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
12572 }
12573
12574 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) {
12575         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12576         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12577         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12578         LDKPublicKey their_node_id_ref;
12579         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12580         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12581         LDKInit msg_conv;
12582         msg_conv.inner = (void*)(msg & (~1));
12583         msg_conv.is_owned = false;
12584         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12585         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12586 }
12587
12588 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) {
12589         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12590         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12591         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12592         LDKPublicKey their_node_id_ref;
12593         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12594         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12595         LDKChannelReestablish msg_conv;
12596         msg_conv.inner = (void*)(msg & (~1));
12597         msg_conv.is_owned = false;
12598         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12599         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12600 }
12601
12602 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) {
12603         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12604         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12605         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12606         LDKPublicKey their_node_id_ref;
12607         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12608         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12609         LDKChannelUpdate msg_conv;
12610         msg_conv.inner = (void*)(msg & (~1));
12611         msg_conv.is_owned = false;
12612         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12613         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12614 }
12615
12616 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) {
12617         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12618         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12619         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12620         LDKPublicKey their_node_id_ref;
12621         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12622         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12623         LDKErrorMessage msg_conv;
12624         msg_conv.inner = (void*)(msg & (~1));
12625         msg_conv.is_owned = false;
12626         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12627         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12628 }
12629
12630 typedef struct LDKRoutingMessageHandler_JCalls {
12631         atomic_size_t refcnt;
12632         JavaVM *vm;
12633         jweak o;
12634         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12635         jmethodID handle_node_announcement_meth;
12636         jmethodID handle_channel_announcement_meth;
12637         jmethodID handle_channel_update_meth;
12638         jmethodID get_next_channel_announcements_meth;
12639         jmethodID get_next_node_announcements_meth;
12640         jmethodID peer_connected_meth;
12641         jmethodID handle_reply_channel_range_meth;
12642         jmethodID handle_reply_short_channel_ids_end_meth;
12643         jmethodID handle_query_channel_range_meth;
12644         jmethodID handle_query_short_channel_ids_meth;
12645 } LDKRoutingMessageHandler_JCalls;
12646 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
12647         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12648         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12649                 JNIEnv *env;
12650                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12651                 if (get_jenv_res == JNI_EDETACHED) {
12652                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12653                 } else {
12654                         DO_ASSERT(get_jenv_res == JNI_OK);
12655                 }
12656                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12657                 if (get_jenv_res == JNI_EDETACHED) {
12658                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12659                 }
12660                 FREE(j_calls);
12661         }
12662 }
12663 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
12664         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12665         JNIEnv *env;
12666         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12667         if (get_jenv_res == JNI_EDETACHED) {
12668                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12669         } else {
12670                 DO_ASSERT(get_jenv_res == JNI_OK);
12671         }
12672         LDKNodeAnnouncement msg_var = *msg;
12673         int64_t msg_ref = 0;
12674         msg_var = NodeAnnouncement_clone(&msg_var);
12675         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12676         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12677         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12678         msg_ref = (uintptr_t)msg_var.inner;
12679         if (msg_var.is_owned) {
12680                 msg_ref |= 1;
12681         }
12682         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12683         CHECK(obj != NULL);
12684         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
12685         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12686                 (*env)->ExceptionDescribe(env);
12687                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12688         }
12689         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12690         CHECK_ACCESS(ret_ptr);
12691         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12692         FREE((void*)ret);
12693         if (get_jenv_res == JNI_EDETACHED) {
12694                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12695         }
12696         return ret_conv;
12697 }
12698 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
12699         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12700         JNIEnv *env;
12701         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12702         if (get_jenv_res == JNI_EDETACHED) {
12703                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12704         } else {
12705                 DO_ASSERT(get_jenv_res == JNI_OK);
12706         }
12707         LDKChannelAnnouncement msg_var = *msg;
12708         int64_t msg_ref = 0;
12709         msg_var = ChannelAnnouncement_clone(&msg_var);
12710         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12711         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12712         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12713         msg_ref = (uintptr_t)msg_var.inner;
12714         if (msg_var.is_owned) {
12715                 msg_ref |= 1;
12716         }
12717         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12718         CHECK(obj != NULL);
12719         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
12720         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12721                 (*env)->ExceptionDescribe(env);
12722                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12723         }
12724         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12725         CHECK_ACCESS(ret_ptr);
12726         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12727         FREE((void*)ret);
12728         if (get_jenv_res == JNI_EDETACHED) {
12729                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12730         }
12731         return ret_conv;
12732 }
12733 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
12734         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12735         JNIEnv *env;
12736         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12737         if (get_jenv_res == JNI_EDETACHED) {
12738                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12739         } else {
12740                 DO_ASSERT(get_jenv_res == JNI_OK);
12741         }
12742         LDKChannelUpdate msg_var = *msg;
12743         int64_t msg_ref = 0;
12744         msg_var = ChannelUpdate_clone(&msg_var);
12745         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12746         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12747         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12748         msg_ref = (uintptr_t)msg_var.inner;
12749         if (msg_var.is_owned) {
12750                 msg_ref |= 1;
12751         }
12752         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12753         CHECK(obj != NULL);
12754         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
12755         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12756                 (*env)->ExceptionDescribe(env);
12757                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
12758         }
12759         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12760         CHECK_ACCESS(ret_ptr);
12761         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12762         FREE((void*)ret);
12763         if (get_jenv_res == JNI_EDETACHED) {
12764                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12765         }
12766         return ret_conv;
12767 }
12768 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
12769         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12770         JNIEnv *env;
12771         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12772         if (get_jenv_res == JNI_EDETACHED) {
12773                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12774         } else {
12775                 DO_ASSERT(get_jenv_res == JNI_OK);
12776         }
12777         int64_t starting_point_conv = starting_point;
12778         int8_t batch_amount_conv = batch_amount;
12779         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12780         CHECK(obj != NULL);
12781         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point_conv, batch_amount_conv);
12782         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12783                 (*env)->ExceptionDescribe(env);
12784                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
12785         }
12786         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
12787         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12788         if (ret_constr.datalen > 0)
12789                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
12790         else
12791                 ret_constr.data = NULL;
12792         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12793         for (size_t h = 0; h < ret_constr.datalen; h++) {
12794                 int64_t ret_conv_59 = ret_vals[h];
12795                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
12796                 CHECK_ACCESS(ret_conv_59_ptr);
12797                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
12798                 FREE((void*)ret_conv_59);
12799                 ret_constr.data[h] = ret_conv_59_conv;
12800         }
12801         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12802         if (get_jenv_res == JNI_EDETACHED) {
12803                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12804         }
12805         return ret_constr;
12806 }
12807 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
12808         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12809         JNIEnv *env;
12810         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12811         if (get_jenv_res == JNI_EDETACHED) {
12812                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12813         } else {
12814                 DO_ASSERT(get_jenv_res == JNI_OK);
12815         }
12816         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
12817         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
12818         int8_t batch_amount_conv = batch_amount;
12819         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12820         CHECK(obj != NULL);
12821         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount_conv);
12822         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12823                 (*env)->ExceptionDescribe(env);
12824                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
12825         }
12826         LDKCVec_NodeAnnouncementZ ret_constr;
12827         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12828         if (ret_constr.datalen > 0)
12829                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
12830         else
12831                 ret_constr.data = NULL;
12832         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12833         for (size_t s = 0; s < ret_constr.datalen; s++) {
12834                 int64_t ret_conv_18 = ret_vals[s];
12835                 LDKNodeAnnouncement ret_conv_18_conv;
12836                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
12837                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
12838                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
12839                 ret_constr.data[s] = ret_conv_18_conv;
12840         }
12841         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12842         if (get_jenv_res == JNI_EDETACHED) {
12843                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12844         }
12845         return ret_constr;
12846 }
12847 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
12848         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12849         JNIEnv *env;
12850         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12851         if (get_jenv_res == JNI_EDETACHED) {
12852                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12853         } else {
12854                 DO_ASSERT(get_jenv_res == JNI_OK);
12855         }
12856         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12857         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12858         LDKInit init_var = *init;
12859         int64_t init_ref = 0;
12860         init_var = Init_clone(&init_var);
12861         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12862         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12863         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
12864         init_ref = (uintptr_t)init_var.inner;
12865         if (init_var.is_owned) {
12866                 init_ref |= 1;
12867         }
12868         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12869         CHECK(obj != NULL);
12870         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
12871         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12872                 (*env)->ExceptionDescribe(env);
12873                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
12874         }
12875         if (get_jenv_res == JNI_EDETACHED) {
12876                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12877         }
12878 }
12879 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
12880         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12881         JNIEnv *env;
12882         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12883         if (get_jenv_res == JNI_EDETACHED) {
12884                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12885         } else {
12886                 DO_ASSERT(get_jenv_res == JNI_OK);
12887         }
12888         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12889         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12890         LDKReplyChannelRange msg_var = msg;
12891         int64_t msg_ref = 0;
12892         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12893         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12894         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12895         msg_ref = (uintptr_t)msg_var.inner;
12896         if (msg_var.is_owned) {
12897                 msg_ref |= 1;
12898         }
12899         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12900         CHECK(obj != NULL);
12901         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
12902         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12903                 (*env)->ExceptionDescribe(env);
12904                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12905         }
12906         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12907         CHECK_ACCESS(ret_ptr);
12908         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12909         FREE((void*)ret);
12910         if (get_jenv_res == JNI_EDETACHED) {
12911                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12912         }
12913         return ret_conv;
12914 }
12915 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
12916         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12917         JNIEnv *env;
12918         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12919         if (get_jenv_res == JNI_EDETACHED) {
12920                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12921         } else {
12922                 DO_ASSERT(get_jenv_res == JNI_OK);
12923         }
12924         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12925         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12926         LDKReplyShortChannelIdsEnd msg_var = msg;
12927         int64_t msg_ref = 0;
12928         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12929         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12930         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12931         msg_ref = (uintptr_t)msg_var.inner;
12932         if (msg_var.is_owned) {
12933                 msg_ref |= 1;
12934         }
12935         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12936         CHECK(obj != NULL);
12937         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
12938         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12939                 (*env)->ExceptionDescribe(env);
12940                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
12941         }
12942         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12943         CHECK_ACCESS(ret_ptr);
12944         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12945         FREE((void*)ret);
12946         if (get_jenv_res == JNI_EDETACHED) {
12947                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12948         }
12949         return ret_conv;
12950 }
12951 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
12952         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12953         JNIEnv *env;
12954         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12955         if (get_jenv_res == JNI_EDETACHED) {
12956                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12957         } else {
12958                 DO_ASSERT(get_jenv_res == JNI_OK);
12959         }
12960         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12961         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12962         LDKQueryChannelRange msg_var = msg;
12963         int64_t msg_ref = 0;
12964         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12965         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12966         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12967         msg_ref = (uintptr_t)msg_var.inner;
12968         if (msg_var.is_owned) {
12969                 msg_ref |= 1;
12970         }
12971         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12972         CHECK(obj != NULL);
12973         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
12974         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12975                 (*env)->ExceptionDescribe(env);
12976                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12977         }
12978         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12979         CHECK_ACCESS(ret_ptr);
12980         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12981         FREE((void*)ret);
12982         if (get_jenv_res == JNI_EDETACHED) {
12983                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12984         }
12985         return ret_conv;
12986 }
12987 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
12988         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12989         JNIEnv *env;
12990         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12991         if (get_jenv_res == JNI_EDETACHED) {
12992                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12993         } else {
12994                 DO_ASSERT(get_jenv_res == JNI_OK);
12995         }
12996         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12997         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12998         LDKQueryShortChannelIds msg_var = msg;
12999         int64_t msg_ref = 0;
13000         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13001         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13002         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13003         msg_ref = (uintptr_t)msg_var.inner;
13004         if (msg_var.is_owned) {
13005                 msg_ref |= 1;
13006         }
13007         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13008         CHECK(obj != NULL);
13009         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
13010         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13011                 (*env)->ExceptionDescribe(env);
13012                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
13013         }
13014         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13015         CHECK_ACCESS(ret_ptr);
13016         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13017         FREE((void*)ret);
13018         if (get_jenv_res == JNI_EDETACHED) {
13019                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13020         }
13021         return ret_conv;
13022 }
13023 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
13024         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
13025         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13026         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13027 }
13028 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13029         jclass c = (*env)->GetObjectClass(env, o);
13030         CHECK(c != NULL);
13031         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
13032         atomic_init(&calls->refcnt, 1);
13033         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13034         calls->o = (*env)->NewWeakGlobalRef(env, o);
13035         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
13036         CHECK(calls->handle_node_announcement_meth != NULL);
13037         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
13038         CHECK(calls->handle_channel_announcement_meth != NULL);
13039         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
13040         CHECK(calls->handle_channel_update_meth != NULL);
13041         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
13042         CHECK(calls->get_next_channel_announcements_meth != NULL);
13043         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
13044         CHECK(calls->get_next_node_announcements_meth != NULL);
13045         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
13046         CHECK(calls->peer_connected_meth != NULL);
13047         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
13048         CHECK(calls->handle_reply_channel_range_meth != NULL);
13049         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
13050         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
13051         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
13052         CHECK(calls->handle_query_channel_range_meth != NULL);
13053         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
13054         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
13055
13056         LDKRoutingMessageHandler ret = {
13057                 .this_arg = (void*) calls,
13058                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
13059                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
13060                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
13061                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
13062                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
13063                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
13064                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
13065                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
13066                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
13067                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
13068                 .free = LDKRoutingMessageHandler_JCalls_free,
13069                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13070         };
13071         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13072         return ret;
13073 }
13074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13075         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
13076         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13077         return (uint64_t)res_ptr;
13078 }
13079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13080         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
13081         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
13082         DO_ASSERT((res_ptr & 1) == 0);
13083         return (int64_t)(res_ptr | 1);
13084 }
13085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13086         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13087         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13088         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13089         LDKNodeAnnouncement msg_conv;
13090         msg_conv.inner = (void*)(msg & (~1));
13091         msg_conv.is_owned = false;
13092         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13093         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13094         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
13095         return (int64_t)ret_conv;
13096 }
13097
13098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13099         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13100         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13101         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13102         LDKChannelAnnouncement msg_conv;
13103         msg_conv.inner = (void*)(msg & (~1));
13104         msg_conv.is_owned = false;
13105         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13106         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13107         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
13108         return (int64_t)ret_conv;
13109 }
13110
13111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13112         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13113         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13114         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13115         LDKChannelUpdate msg_conv;
13116         msg_conv.inner = (void*)(msg & (~1));
13117         msg_conv.is_owned = false;
13118         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13119         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13120         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
13121         return (int64_t)ret_conv;
13122 }
13123
13124 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) {
13125         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13126         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13127         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13128         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
13129         int64_tArray ret_arr = NULL;
13130         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13131         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13132         for (size_t h = 0; h < ret_var.datalen; h++) {
13133                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13134                 *ret_conv_59_conv = ret_var.data[h];
13135                 ret_arr_ptr[h] = ((int64_t)ret_conv_59_conv);
13136         }
13137         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13138         FREE(ret_var.data);
13139         return ret_arr;
13140 }
13141
13142 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) {
13143         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13144         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13145         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13146         LDKPublicKey starting_point_ref;
13147         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
13148         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
13149         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
13150         int64_tArray ret_arr = NULL;
13151         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13152         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13153         for (size_t s = 0; s < ret_var.datalen; s++) {
13154                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
13155                 int64_t ret_conv_18_ref = 0;
13156                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13157                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13158                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
13159                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
13160                 if (ret_conv_18_var.is_owned) {
13161                         ret_conv_18_ref |= 1;
13162                 }
13163                 ret_arr_ptr[s] = ret_conv_18_ref;
13164         }
13165         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13166         FREE(ret_var.data);
13167         return ret_arr;
13168 }
13169
13170 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) {
13171         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13172         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13173         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13174         LDKPublicKey their_node_id_ref;
13175         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13176         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13177         LDKInit init_conv;
13178         init_conv.inner = (void*)(init & (~1));
13179         init_conv.is_owned = false;
13180         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13181         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13182 }
13183
13184 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) {
13185         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13186         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13187         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13188         LDKPublicKey their_node_id_ref;
13189         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13190         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13191         LDKReplyChannelRange msg_conv;
13192         msg_conv.inner = (void*)(msg & (~1));
13193         msg_conv.is_owned = (msg & 1) || (msg == 0);
13194         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13195         msg_conv = ReplyChannelRange_clone(&msg_conv);
13196         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13197         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13198         return (int64_t)ret_conv;
13199 }
13200
13201 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) {
13202         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13203         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13204         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13205         LDKPublicKey their_node_id_ref;
13206         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13207         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13208         LDKReplyShortChannelIdsEnd msg_conv;
13209         msg_conv.inner = (void*)(msg & (~1));
13210         msg_conv.is_owned = (msg & 1) || (msg == 0);
13211         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13212         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
13213         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13214         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13215         return (int64_t)ret_conv;
13216 }
13217
13218 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) {
13219         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13220         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13221         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13222         LDKPublicKey their_node_id_ref;
13223         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13224         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13225         LDKQueryChannelRange msg_conv;
13226         msg_conv.inner = (void*)(msg & (~1));
13227         msg_conv.is_owned = (msg & 1) || (msg == 0);
13228         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13229         msg_conv = QueryChannelRange_clone(&msg_conv);
13230         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13231         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13232         return (int64_t)ret_conv;
13233 }
13234
13235 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) {
13236         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13237         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13238         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13239         LDKPublicKey their_node_id_ref;
13240         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13241         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13242         LDKQueryShortChannelIds msg_conv;
13243         msg_conv.inner = (void*)(msg & (~1));
13244         msg_conv.is_owned = (msg & 1) || (msg == 0);
13245         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13246         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13247         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13248         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13249         return (int64_t)ret_conv;
13250 }
13251
13252 typedef struct LDKCustomMessageReader_JCalls {
13253         atomic_size_t refcnt;
13254         JavaVM *vm;
13255         jweak o;
13256         jmethodID read_meth;
13257 } LDKCustomMessageReader_JCalls;
13258 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
13259         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13260         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13261                 JNIEnv *env;
13262                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13263                 if (get_jenv_res == JNI_EDETACHED) {
13264                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13265                 } else {
13266                         DO_ASSERT(get_jenv_res == JNI_OK);
13267                 }
13268                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13269                 if (get_jenv_res == JNI_EDETACHED) {
13270                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13271                 }
13272                 FREE(j_calls);
13273         }
13274 }
13275 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
13276         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13277         JNIEnv *env;
13278         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13279         if (get_jenv_res == JNI_EDETACHED) {
13280                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13281         } else {
13282                 DO_ASSERT(get_jenv_res == JNI_OK);
13283         }
13284         int16_t message_type_conv = message_type;
13285         LDKu8slice buffer_var = buffer;
13286         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
13287         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
13288         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13289         CHECK(obj != NULL);
13290         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
13291         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13292                 (*env)->ExceptionDescribe(env);
13293                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
13294         }
13295         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13296         CHECK_ACCESS(ret_ptr);
13297         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
13298         FREE((void*)ret);
13299         if (get_jenv_res == JNI_EDETACHED) {
13300                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13301         }
13302         return ret_conv;
13303 }
13304 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
13305         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
13306         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13307 }
13308 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
13309         jclass c = (*env)->GetObjectClass(env, o);
13310         CHECK(c != NULL);
13311         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
13312         atomic_init(&calls->refcnt, 1);
13313         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13314         calls->o = (*env)->NewWeakGlobalRef(env, o);
13315         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
13316         CHECK(calls->read_meth != NULL);
13317
13318         LDKCustomMessageReader ret = {
13319                 .this_arg = (void*) calls,
13320                 .read = read_LDKCustomMessageReader_jcall,
13321                 .free = LDKCustomMessageReader_JCalls_free,
13322         };
13323         return ret;
13324 }
13325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
13326         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
13327         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
13328         return (uint64_t)res_ptr;
13329 }
13330 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) {
13331         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13332         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13333         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
13334         LDKu8slice buffer_ref;
13335         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
13336         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
13337         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
13338         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
13339         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
13340         return (int64_t)ret_conv;
13341 }
13342
13343 typedef struct LDKCustomMessageHandler_JCalls {
13344         atomic_size_t refcnt;
13345         JavaVM *vm;
13346         jweak o;
13347         LDKCustomMessageReader_JCalls* CustomMessageReader;
13348         jmethodID handle_custom_message_meth;
13349         jmethodID get_and_clear_pending_msg_meth;
13350 } LDKCustomMessageHandler_JCalls;
13351 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
13352         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13353         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13354                 JNIEnv *env;
13355                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13356                 if (get_jenv_res == JNI_EDETACHED) {
13357                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13358                 } else {
13359                         DO_ASSERT(get_jenv_res == JNI_OK);
13360                 }
13361                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13362                 if (get_jenv_res == JNI_EDETACHED) {
13363                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13364                 }
13365                 FREE(j_calls);
13366         }
13367 }
13368 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
13369         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13370         JNIEnv *env;
13371         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13372         if (get_jenv_res == JNI_EDETACHED) {
13373                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13374         } else {
13375                 DO_ASSERT(get_jenv_res == JNI_OK);
13376         }
13377         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
13378         *msg_ret = msg;
13379         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
13380         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
13381         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13382         CHECK(obj != NULL);
13383         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (int64_t)msg_ret, sender_node_id_arr);
13384         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13385                 (*env)->ExceptionDescribe(env);
13386                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
13387         }
13388         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13389         CHECK_ACCESS(ret_ptr);
13390         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13391         FREE((void*)ret);
13392         if (get_jenv_res == JNI_EDETACHED) {
13393                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13394         }
13395         return ret_conv;
13396 }
13397 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
13398         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13399         JNIEnv *env;
13400         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13401         if (get_jenv_res == JNI_EDETACHED) {
13402                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13403         } else {
13404                 DO_ASSERT(get_jenv_res == JNI_OK);
13405         }
13406         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13407         CHECK(obj != NULL);
13408         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
13409         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13410                 (*env)->ExceptionDescribe(env);
13411                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
13412         }
13413         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
13414         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13415         if (ret_constr.datalen > 0)
13416                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13417         else
13418                 ret_constr.data = NULL;
13419         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13420         for (size_t z = 0; z < ret_constr.datalen; z++) {
13421                 int64_t ret_conv_25 = ret_vals[z];
13422                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
13423                 CHECK_ACCESS(ret_conv_25_ptr);
13424                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
13425                 FREE((void*)ret_conv_25);
13426                 ret_constr.data[z] = ret_conv_25_conv;
13427         }
13428         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13429         if (get_jenv_res == JNI_EDETACHED) {
13430                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13431         }
13432         return ret_constr;
13433 }
13434 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
13435         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
13436         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13437         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
13438 }
13439 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13440         jclass c = (*env)->GetObjectClass(env, o);
13441         CHECK(c != NULL);
13442         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
13443         atomic_init(&calls->refcnt, 1);
13444         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13445         calls->o = (*env)->NewWeakGlobalRef(env, o);
13446         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
13447         CHECK(calls->handle_custom_message_meth != NULL);
13448         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
13449         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
13450
13451         LDKCustomMessageHandler ret = {
13452                 .this_arg = (void*) calls,
13453                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
13454                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
13455                 .free = LDKCustomMessageHandler_JCalls_free,
13456                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
13457         };
13458         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
13459         return ret;
13460 }
13461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13462         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
13463         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
13464         return (uint64_t)res_ptr;
13465 }
13466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
13467         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
13468         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
13469         DO_ASSERT((res_ptr & 1) == 0);
13470         return (int64_t)(res_ptr | 1);
13471 }
13472 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) {
13473         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13474         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13475         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13476         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
13477         CHECK_ACCESS(msg_ptr);
13478         LDKType msg_conv = *(LDKType*)(msg_ptr);
13479         if (msg_conv.free == LDKType_JCalls_free) {
13480                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13481                 LDKType_JCalls_cloned(&msg_conv);
13482         }
13483         LDKPublicKey sender_node_id_ref;
13484         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
13485         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
13486         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13487         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
13488         return (int64_t)ret_conv;
13489 }
13490
13491 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
13492         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13493         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13494         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13495         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
13496         int64_tArray ret_arr = NULL;
13497         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13498         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13499         for (size_t z = 0; z < ret_var.datalen; z++) {
13500                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13501                 *ret_conv_25_conv = ret_var.data[z];
13502                 ret_arr_ptr[z] = ((int64_t)ret_conv_25_conv);
13503         }
13504         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13505         FREE(ret_var.data);
13506         return ret_arr;
13507 }
13508
13509 typedef struct LDKSocketDescriptor_JCalls {
13510         atomic_size_t refcnt;
13511         JavaVM *vm;
13512         jweak o;
13513         jmethodID send_data_meth;
13514         jmethodID disconnect_socket_meth;
13515         jmethodID eq_meth;
13516         jmethodID hash_meth;
13517 } LDKSocketDescriptor_JCalls;
13518 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
13519         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13520         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13521                 JNIEnv *env;
13522                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13523                 if (get_jenv_res == JNI_EDETACHED) {
13524                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13525                 } else {
13526                         DO_ASSERT(get_jenv_res == JNI_OK);
13527                 }
13528                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13529                 if (get_jenv_res == JNI_EDETACHED) {
13530                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13531                 }
13532                 FREE(j_calls);
13533         }
13534 }
13535 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
13536         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13537         JNIEnv *env;
13538         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13539         if (get_jenv_res == JNI_EDETACHED) {
13540                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13541         } else {
13542                 DO_ASSERT(get_jenv_res == JNI_OK);
13543         }
13544         LDKu8slice data_var = data;
13545         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
13546         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
13547         jboolean resume_read_conv = resume_read;
13548         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13549         CHECK(obj != NULL);
13550         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
13551         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13552                 (*env)->ExceptionDescribe(env);
13553                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
13554         }
13555         if (get_jenv_res == JNI_EDETACHED) {
13556                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13557         }
13558         return ret;
13559 }
13560 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
13561         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13562         JNIEnv *env;
13563         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13564         if (get_jenv_res == JNI_EDETACHED) {
13565                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13566         } else {
13567                 DO_ASSERT(get_jenv_res == JNI_OK);
13568         }
13569         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13570         CHECK(obj != NULL);
13571         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
13572         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13573                 (*env)->ExceptionDescribe(env);
13574                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
13575         }
13576         if (get_jenv_res == JNI_EDETACHED) {
13577                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13578         }
13579 }
13580 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
13581         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13582         JNIEnv *env;
13583         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13584         if (get_jenv_res == JNI_EDETACHED) {
13585                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13586         } else {
13587                 DO_ASSERT(get_jenv_res == JNI_OK);
13588         }
13589         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13590         *other_arg_clone = SocketDescriptor_clone(other_arg);
13591         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13592         CHECK(obj != NULL);
13593         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (int64_t)other_arg_clone);
13594         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13595                 (*env)->ExceptionDescribe(env);
13596                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
13597         }
13598         if (get_jenv_res == JNI_EDETACHED) {
13599                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13600         }
13601         return ret;
13602 }
13603 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
13604         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13605         JNIEnv *env;
13606         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13607         if (get_jenv_res == JNI_EDETACHED) {
13608                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13609         } else {
13610                 DO_ASSERT(get_jenv_res == JNI_OK);
13611         }
13612         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13613         CHECK(obj != NULL);
13614         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
13615         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13616                 (*env)->ExceptionDescribe(env);
13617                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
13618         }
13619         if (get_jenv_res == JNI_EDETACHED) {
13620                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13621         }
13622         return ret;
13623 }
13624 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
13625         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
13626         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13627 }
13628 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
13629         jclass c = (*env)->GetObjectClass(env, o);
13630         CHECK(c != NULL);
13631         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
13632         atomic_init(&calls->refcnt, 1);
13633         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13634         calls->o = (*env)->NewWeakGlobalRef(env, o);
13635         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
13636         CHECK(calls->send_data_meth != NULL);
13637         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
13638         CHECK(calls->disconnect_socket_meth != NULL);
13639         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
13640         CHECK(calls->eq_meth != NULL);
13641         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
13642         CHECK(calls->hash_meth != NULL);
13643
13644         LDKSocketDescriptor ret = {
13645                 .this_arg = (void*) calls,
13646                 .send_data = send_data_LDKSocketDescriptor_jcall,
13647                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
13648                 .eq = eq_LDKSocketDescriptor_jcall,
13649                 .hash = hash_LDKSocketDescriptor_jcall,
13650                 .cloned = LDKSocketDescriptor_JCalls_cloned,
13651                 .free = LDKSocketDescriptor_JCalls_free,
13652         };
13653         return ret;
13654 }
13655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
13656         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13657         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
13658         return (uint64_t)res_ptr;
13659 }
13660 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) {
13661         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13662         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13663         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
13664         LDKu8slice data_ref;
13665         data_ref.datalen = (*env)->GetArrayLength(env, data);
13666         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
13667         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
13668         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
13669         return ret_conv;
13670 }
13671
13672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
13673         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13674         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13675         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
13676         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
13677 }
13678
13679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
13680         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13681         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13682         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
13683         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
13684         return ret_conv;
13685 }
13686
13687 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
13688 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
13689 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
13690 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
13691 static jclass LDKEffectiveCapacity_Total_class = NULL;
13692 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
13693 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
13694 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
13695 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
13696 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
13697 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
13698         LDKEffectiveCapacity_ExactLiquidity_class =
13699                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
13700         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
13701         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
13702         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
13703         LDKEffectiveCapacity_MaximumHTLC_class =
13704                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
13705         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
13706         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
13707         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
13708         LDKEffectiveCapacity_Total_class =
13709                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
13710         CHECK(LDKEffectiveCapacity_Total_class != NULL);
13711         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
13712         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
13713         LDKEffectiveCapacity_Infinite_class =
13714                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
13715         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
13716         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
13717         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
13718         LDKEffectiveCapacity_Unknown_class =
13719                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
13720         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
13721         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
13722         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
13723 }
13724 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13725         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
13726         switch(obj->tag) {
13727                 case LDKEffectiveCapacity_ExactLiquidity: {
13728                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
13729                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
13730                 }
13731                 case LDKEffectiveCapacity_MaximumHTLC: {
13732                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
13733                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
13734                 }
13735                 case LDKEffectiveCapacity_Total: {
13736                         int64_t capacity_msat_conv = obj->total.capacity_msat;
13737                         int64_t htlc_maximum_msat_ref = ((uintptr_t)&obj->total.htlc_maximum_msat) | 1;
13738                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_ref);
13739                 }
13740                 case LDKEffectiveCapacity_Infinite: {
13741                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
13742                 }
13743                 case LDKEffectiveCapacity_Unknown: {
13744                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
13745                 }
13746                 default: abort();
13747         }
13748 }
13749 typedef struct LDKLockableScore_JCalls {
13750         atomic_size_t refcnt;
13751         JavaVM *vm;
13752         jweak o;
13753         jmethodID lock_meth;
13754 } LDKLockableScore_JCalls;
13755 static void LDKLockableScore_JCalls_free(void* this_arg) {
13756         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13757         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13758                 JNIEnv *env;
13759                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13760                 if (get_jenv_res == JNI_EDETACHED) {
13761                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13762                 } else {
13763                         DO_ASSERT(get_jenv_res == JNI_OK);
13764                 }
13765                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13766                 if (get_jenv_res == JNI_EDETACHED) {
13767                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13768                 }
13769                 FREE(j_calls);
13770         }
13771 }
13772 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
13773         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13774         JNIEnv *env;
13775         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13776         if (get_jenv_res == JNI_EDETACHED) {
13777                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13778         } else {
13779                 DO_ASSERT(get_jenv_res == JNI_OK);
13780         }
13781         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13782         CHECK(obj != NULL);
13783         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
13784         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13785                 (*env)->ExceptionDescribe(env);
13786                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
13787         }
13788         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13789         CHECK_ACCESS(ret_ptr);
13790         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
13791         if (ret_conv.free == LDKScore_JCalls_free) {
13792                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13793                 LDKScore_JCalls_cloned(&ret_conv);
13794         }// WARNING: we may need a move here but no clone is available for LDKScore
13795         
13796         if (get_jenv_res == JNI_EDETACHED) {
13797                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13798         }
13799         return ret_conv;
13800 }
13801 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
13802         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
13803         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13804 }
13805 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
13806         jclass c = (*env)->GetObjectClass(env, o);
13807         CHECK(c != NULL);
13808         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
13809         atomic_init(&calls->refcnt, 1);
13810         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13811         calls->o = (*env)->NewWeakGlobalRef(env, o);
13812         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
13813         CHECK(calls->lock_meth != NULL);
13814
13815         LDKLockableScore ret = {
13816                 .this_arg = (void*) calls,
13817                 .lock = lock_LDKLockableScore_jcall,
13818                 .free = LDKLockableScore_JCalls_free,
13819         };
13820         return ret;
13821 }
13822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
13823         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
13824         *res_ptr = LDKLockableScore_init(env, clz, o);
13825         return (uint64_t)res_ptr;
13826 }
13827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
13828         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13829         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13830         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
13831         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
13832         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
13833         return (int64_t)ret_ret;
13834 }
13835
13836 static jclass LDKGossipSync_P2P_class = NULL;
13837 static jmethodID LDKGossipSync_P2P_meth = NULL;
13838 static jclass LDKGossipSync_Rapid_class = NULL;
13839 static jmethodID LDKGossipSync_Rapid_meth = NULL;
13840 static jclass LDKGossipSync_None_class = NULL;
13841 static jmethodID LDKGossipSync_None_meth = NULL;
13842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
13843         LDKGossipSync_P2P_class =
13844                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
13845         CHECK(LDKGossipSync_P2P_class != NULL);
13846         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
13847         CHECK(LDKGossipSync_P2P_meth != NULL);
13848         LDKGossipSync_Rapid_class =
13849                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
13850         CHECK(LDKGossipSync_Rapid_class != NULL);
13851         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
13852         CHECK(LDKGossipSync_Rapid_meth != NULL);
13853         LDKGossipSync_None_class =
13854                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
13855         CHECK(LDKGossipSync_None_class != NULL);
13856         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
13857         CHECK(LDKGossipSync_None_meth != NULL);
13858 }
13859 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13860         LDKGossipSync *obj = (LDKGossipSync*)(ptr & ~1);
13861         switch(obj->tag) {
13862                 case LDKGossipSync_P2P: {
13863                         LDKP2PGossipSync p2p_var = obj->p2p;
13864                         int64_t p2p_ref = 0;
13865                         CHECK((((uintptr_t)p2p_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13866                         CHECK((((uintptr_t)&p2p_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13867                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
13868                         p2p_ref = (uintptr_t)p2p_var.inner & ~1;
13869                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
13870                 }
13871                 case LDKGossipSync_Rapid: {
13872                         LDKRapidGossipSync rapid_var = obj->rapid;
13873                         int64_t rapid_ref = 0;
13874                         CHECK((((uintptr_t)rapid_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13875                         CHECK((((uintptr_t)&rapid_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13876                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
13877                         rapid_ref = (uintptr_t)rapid_var.inner & ~1;
13878                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
13879                 }
13880                 case LDKGossipSync_None: {
13881                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
13882                 }
13883                 default: abort();
13884         }
13885 }
13886 static jclass LDKFallback_SegWitProgram_class = NULL;
13887 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
13888 static jclass LDKFallback_PubKeyHash_class = NULL;
13889 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
13890 static jclass LDKFallback_ScriptHash_class = NULL;
13891 static jmethodID LDKFallback_ScriptHash_meth = NULL;
13892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
13893         LDKFallback_SegWitProgram_class =
13894                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
13895         CHECK(LDKFallback_SegWitProgram_class != NULL);
13896         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
13897         CHECK(LDKFallback_SegWitProgram_meth != NULL);
13898         LDKFallback_PubKeyHash_class =
13899                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
13900         CHECK(LDKFallback_PubKeyHash_class != NULL);
13901         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
13902         CHECK(LDKFallback_PubKeyHash_meth != NULL);
13903         LDKFallback_ScriptHash_class =
13904                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
13905         CHECK(LDKFallback_ScriptHash_class != NULL);
13906         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
13907         CHECK(LDKFallback_ScriptHash_meth != NULL);
13908 }
13909 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13910         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
13911         switch(obj->tag) {
13912                 case LDKFallback_SegWitProgram: {
13913                         uint8_t version_val = obj->seg_wit_program.version._0;
13914                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
13915                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
13916                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
13917                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
13918                 }
13919                 case LDKFallback_PubKeyHash: {
13920                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
13921                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
13922                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
13923                 }
13924                 case LDKFallback_ScriptHash: {
13925                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
13926                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
13927                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
13928                 }
13929                 default: abort();
13930         }
13931 }
13932 typedef struct LDKPayer_JCalls {
13933         atomic_size_t refcnt;
13934         JavaVM *vm;
13935         jweak o;
13936         jmethodID node_id_meth;
13937         jmethodID first_hops_meth;
13938         jmethodID send_payment_meth;
13939         jmethodID send_spontaneous_payment_meth;
13940         jmethodID retry_payment_meth;
13941         jmethodID abandon_payment_meth;
13942 } LDKPayer_JCalls;
13943 static void LDKPayer_JCalls_free(void* this_arg) {
13944         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13945         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13946                 JNIEnv *env;
13947                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13948                 if (get_jenv_res == JNI_EDETACHED) {
13949                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13950                 } else {
13951                         DO_ASSERT(get_jenv_res == JNI_OK);
13952                 }
13953                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13954                 if (get_jenv_res == JNI_EDETACHED) {
13955                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13956                 }
13957                 FREE(j_calls);
13958         }
13959 }
13960 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
13961         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13962         JNIEnv *env;
13963         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13964         if (get_jenv_res == JNI_EDETACHED) {
13965                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13966         } else {
13967                 DO_ASSERT(get_jenv_res == JNI_OK);
13968         }
13969         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13970         CHECK(obj != NULL);
13971         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
13972         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13973                 (*env)->ExceptionDescribe(env);
13974                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
13975         }
13976         LDKPublicKey ret_ref;
13977         CHECK((*env)->GetArrayLength(env, ret) == 33);
13978         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
13979         if (get_jenv_res == JNI_EDETACHED) {
13980                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13981         }
13982         return ret_ref;
13983 }
13984 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
13985         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13986         JNIEnv *env;
13987         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13988         if (get_jenv_res == JNI_EDETACHED) {
13989                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13990         } else {
13991                 DO_ASSERT(get_jenv_res == JNI_OK);
13992         }
13993         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13994         CHECK(obj != NULL);
13995         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
13996         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13997                 (*env)->ExceptionDescribe(env);
13998                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
13999         }
14000         LDKCVec_ChannelDetailsZ ret_constr;
14001         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
14002         if (ret_constr.datalen > 0)
14003                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14004         else
14005                 ret_constr.data = NULL;
14006         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
14007         for (size_t q = 0; q < ret_constr.datalen; q++) {
14008                 int64_t ret_conv_16 = ret_vals[q];
14009                 LDKChannelDetails ret_conv_16_conv;
14010                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
14011                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
14012                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
14013                 ret_constr.data[q] = ret_conv_16_conv;
14014         }
14015         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
14016         if (get_jenv_res == JNI_EDETACHED) {
14017                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14018         }
14019         return ret_constr;
14020 }
14021 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
14022         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14023         JNIEnv *env;
14024         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14025         if (get_jenv_res == JNI_EDETACHED) {
14026                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14027         } else {
14028                 DO_ASSERT(get_jenv_res == JNI_OK);
14029         }
14030         LDKRoute route_var = *route;
14031         int64_t route_ref = 0;
14032         route_var = Route_clone(&route_var);
14033         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14034         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14035         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14036         route_ref = (uintptr_t)route_var.inner;
14037         if (route_var.is_owned) {
14038                 route_ref |= 1;
14039         }
14040         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14041         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
14042         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
14043         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
14044         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14045         CHECK(obj != NULL);
14046         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
14047         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14048                 (*env)->ExceptionDescribe(env);
14049                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
14050         }
14051         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14052         CHECK_ACCESS(ret_ptr);
14053         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14054         FREE((void*)ret);
14055         if (get_jenv_res == JNI_EDETACHED) {
14056                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14057         }
14058         return ret_conv;
14059 }
14060 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
14061         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14062         JNIEnv *env;
14063         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14064         if (get_jenv_res == JNI_EDETACHED) {
14065                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14066         } else {
14067                 DO_ASSERT(get_jenv_res == JNI_OK);
14068         }
14069         LDKRoute route_var = *route;
14070         int64_t route_ref = 0;
14071         route_var = Route_clone(&route_var);
14072         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14073         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14074         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14075         route_ref = (uintptr_t)route_var.inner;
14076         if (route_var.is_owned) {
14077                 route_ref |= 1;
14078         }
14079         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
14080         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
14081         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14082         CHECK(obj != NULL);
14083         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
14084         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14085                 (*env)->ExceptionDescribe(env);
14086                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
14087         }
14088         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14089         CHECK_ACCESS(ret_ptr);
14090         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14091         FREE((void*)ret);
14092         if (get_jenv_res == JNI_EDETACHED) {
14093                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14094         }
14095         return ret_conv;
14096 }
14097 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
14098         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14099         JNIEnv *env;
14100         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14101         if (get_jenv_res == JNI_EDETACHED) {
14102                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14103         } else {
14104                 DO_ASSERT(get_jenv_res == JNI_OK);
14105         }
14106         LDKRoute route_var = *route;
14107         int64_t route_ref = 0;
14108         route_var = Route_clone(&route_var);
14109         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14110         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14111         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14112         route_ref = (uintptr_t)route_var.inner;
14113         if (route_var.is_owned) {
14114                 route_ref |= 1;
14115         }
14116         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14117         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14118         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14119         CHECK(obj != NULL);
14120         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
14121         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14122                 (*env)->ExceptionDescribe(env);
14123                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
14124         }
14125         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14126         CHECK_ACCESS(ret_ptr);
14127         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
14128         FREE((void*)ret);
14129         if (get_jenv_res == JNI_EDETACHED) {
14130                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14131         }
14132         return ret_conv;
14133 }
14134 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
14135         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14136         JNIEnv *env;
14137         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14138         if (get_jenv_res == JNI_EDETACHED) {
14139                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14140         } else {
14141                 DO_ASSERT(get_jenv_res == JNI_OK);
14142         }
14143         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14144         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14145         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14146         CHECK(obj != NULL);
14147         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
14148         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14149                 (*env)->ExceptionDescribe(env);
14150                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
14151         }
14152         if (get_jenv_res == JNI_EDETACHED) {
14153                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14154         }
14155 }
14156 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
14157         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
14158         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14159 }
14160 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
14161         jclass c = (*env)->GetObjectClass(env, o);
14162         CHECK(c != NULL);
14163         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
14164         atomic_init(&calls->refcnt, 1);
14165         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14166         calls->o = (*env)->NewWeakGlobalRef(env, o);
14167         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
14168         CHECK(calls->node_id_meth != NULL);
14169         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
14170         CHECK(calls->first_hops_meth != NULL);
14171         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
14172         CHECK(calls->send_payment_meth != NULL);
14173         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
14174         CHECK(calls->send_spontaneous_payment_meth != NULL);
14175         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
14176         CHECK(calls->retry_payment_meth != NULL);
14177         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
14178         CHECK(calls->abandon_payment_meth != NULL);
14179
14180         LDKPayer ret = {
14181                 .this_arg = (void*) calls,
14182                 .node_id = node_id_LDKPayer_jcall,
14183                 .first_hops = first_hops_LDKPayer_jcall,
14184                 .send_payment = send_payment_LDKPayer_jcall,
14185                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
14186                 .retry_payment = retry_payment_LDKPayer_jcall,
14187                 .abandon_payment = abandon_payment_LDKPayer_jcall,
14188                 .free = LDKPayer_JCalls_free,
14189         };
14190         return ret;
14191 }
14192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
14193         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
14194         *res_ptr = LDKPayer_init(env, clz, o);
14195         return (uint64_t)res_ptr;
14196 }
14197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14198         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14199         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14200         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14201         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14202         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
14203         return ret_arr;
14204 }
14205
14206 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
14207         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14208         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14209         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14210         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
14211         int64_tArray ret_arr = NULL;
14212         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14213         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14214         for (size_t q = 0; q < ret_var.datalen; q++) {
14215                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
14216                 int64_t ret_conv_16_ref = 0;
14217                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14218                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14219                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
14220                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
14221                 if (ret_conv_16_var.is_owned) {
14222                         ret_conv_16_ref |= 1;
14223                 }
14224                 ret_arr_ptr[q] = ret_conv_16_ref;
14225         }
14226         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14227         FREE(ret_var.data);
14228         return ret_arr;
14229 }
14230
14231 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) {
14232         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14233         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14234         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14235         LDKRoute route_conv;
14236         route_conv.inner = (void*)(route & (~1));
14237         route_conv.is_owned = false;
14238         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14239         LDKThirtyTwoBytes payment_hash_ref;
14240         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14241         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
14242         LDKThirtyTwoBytes payment_secret_ref;
14243         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
14244         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
14245         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14246         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
14247         return (int64_t)ret_conv;
14248 }
14249
14250 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) {
14251         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14252         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14253         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14254         LDKRoute route_conv;
14255         route_conv.inner = (void*)(route & (~1));
14256         route_conv.is_owned = false;
14257         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14258         LDKThirtyTwoBytes payment_preimage_ref;
14259         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
14260         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
14261         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14262         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
14263         return (int64_t)ret_conv;
14264 }
14265
14266 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) {
14267         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14268         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14269         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14270         LDKRoute route_conv;
14271         route_conv.inner = (void*)(route & (~1));
14272         route_conv.is_owned = false;
14273         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14274         LDKThirtyTwoBytes payment_id_ref;
14275         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14276         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14277         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14278         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
14279         return (int64_t)ret_conv;
14280 }
14281
14282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
14283         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14284         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14285         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14286         LDKThirtyTwoBytes payment_id_ref;
14287         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14288         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14289         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
14290 }
14291
14292 typedef struct LDKRouter_JCalls {
14293         atomic_size_t refcnt;
14294         JavaVM *vm;
14295         jweak o;
14296         jmethodID find_route_meth;
14297 } LDKRouter_JCalls;
14298 static void LDKRouter_JCalls_free(void* this_arg) {
14299         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14300         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14301                 JNIEnv *env;
14302                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14303                 if (get_jenv_res == JNI_EDETACHED) {
14304                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14305                 } else {
14306                         DO_ASSERT(get_jenv_res == JNI_OK);
14307                 }
14308                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14309                 if (get_jenv_res == JNI_EDETACHED) {
14310                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14311                 }
14312                 FREE(j_calls);
14313         }
14314 }
14315 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) {
14316         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14317         JNIEnv *env;
14318         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14319         if (get_jenv_res == JNI_EDETACHED) {
14320                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14321         } else {
14322                 DO_ASSERT(get_jenv_res == JNI_OK);
14323         }
14324         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14325         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14326         LDKRouteParameters route_params_var = *route_params;
14327         int64_t route_params_ref = 0;
14328         route_params_var = RouteParameters_clone(&route_params_var);
14329         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14330         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14331         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14332         route_params_ref = (uintptr_t)route_params_var.inner;
14333         if (route_params_var.is_owned) {
14334                 route_params_ref |= 1;
14335         }
14336         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14337         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
14338         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14339         int64_tArray first_hops_arr = NULL;
14340         if (first_hops != NULL) {
14341                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14342                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14343                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14344                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14345                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14346                         int64_t first_hops_conv_16_ref = 0;
14347                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14348                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14349                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14350                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
14351                         if (first_hops_conv_16_var.is_owned) {
14352                                 first_hops_conv_16_ref |= 1;
14353                         }
14354                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14355                 }
14356                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14357         }
14358         // WARNING: This object doesn't live past this scope, needs clone!
14359         int64_t ret_scorer = ((uintptr_t)scorer) | 1;
14360         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14361         CHECK(obj != NULL);
14362         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);
14363         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14364                 (*env)->ExceptionDescribe(env);
14365                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
14366         }
14367         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
14368         CHECK_ACCESS(ret_ptr);
14369         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14370         FREE((void*)ret);
14371         if (get_jenv_res == JNI_EDETACHED) {
14372                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14373         }
14374         return ret_conv;
14375 }
14376 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
14377         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
14378         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14379 }
14380 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
14381         jclass c = (*env)->GetObjectClass(env, o);
14382         CHECK(c != NULL);
14383         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
14384         atomic_init(&calls->refcnt, 1);
14385         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14386         calls->o = (*env)->NewWeakGlobalRef(env, o);
14387         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
14388         CHECK(calls->find_route_meth != NULL);
14389
14390         LDKRouter ret = {
14391                 .this_arg = (void*) calls,
14392                 .find_route = find_route_LDKRouter_jcall,
14393                 .free = LDKRouter_JCalls_free,
14394         };
14395         return ret;
14396 }
14397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
14398         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
14399         *res_ptr = LDKRouter_init(env, clz, o);
14400         return (uint64_t)res_ptr;
14401 }
14402 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) {
14403         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14404         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14405         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14406         LDKPublicKey payer_ref;
14407         CHECK((*env)->GetArrayLength(env, payer) == 33);
14408         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
14409         LDKRouteParameters route_params_conv;
14410         route_params_conv.inner = (void*)(route_params & (~1));
14411         route_params_conv.is_owned = false;
14412         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
14413         unsigned char payment_hash_arr[32];
14414         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14415         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
14416         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
14417         LDKCVec_ChannelDetailsZ first_hops_constr;
14418         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
14419         if (first_hops != NULL) {
14420                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
14421                 if (first_hops_constr.datalen > 0)
14422                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14423                 else
14424                         first_hops_constr.data = NULL;
14425                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
14426                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14427                         int64_t first_hops_conv_16 = first_hops_vals[q];
14428                         LDKChannelDetails first_hops_conv_16_conv;
14429                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
14430                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
14431                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
14432                         first_hops_constr.data[q] = first_hops_conv_16_conv;
14433                 }
14434                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
14435                 first_hops_ptr = &first_hops_constr;
14436         }
14437         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
14438         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
14439         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
14440         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14441         *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);
14442         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
14443         return (int64_t)ret_conv;
14444 }
14445
14446 static jclass LDKRetry_Attempts_class = NULL;
14447 static jmethodID LDKRetry_Attempts_meth = NULL;
14448 static jclass LDKRetry_Timeout_class = NULL;
14449 static jmethodID LDKRetry_Timeout_meth = NULL;
14450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
14451         LDKRetry_Attempts_class =
14452                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
14453         CHECK(LDKRetry_Attempts_class != NULL);
14454         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
14455         CHECK(LDKRetry_Attempts_meth != NULL);
14456         LDKRetry_Timeout_class =
14457                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
14458         CHECK(LDKRetry_Timeout_class != NULL);
14459         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
14460         CHECK(LDKRetry_Timeout_meth != NULL);
14461 }
14462 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14463         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
14464         switch(obj->tag) {
14465                 case LDKRetry_Attempts: {
14466                         int64_t attempts_conv = obj->attempts;
14467                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
14468                 }
14469                 case LDKRetry_Timeout: {
14470                         int64_t timeout_conv = obj->timeout;
14471                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
14472                 }
14473                 default: abort();
14474         }
14475 }
14476 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14477         LDKStr ret_str = _ldk_get_compiled_version();
14478         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14479         Str_free(ret_str);
14480         return ret_conv;
14481 }
14482
14483 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14484         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
14485         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14486         Str_free(ret_str);
14487         return ret_conv;
14488 }
14489
14490 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
14491         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14492         *ret_copy = Bech32Error_clone(arg);
14493 int64_t ret_ref = (uintptr_t)ret_copy;
14494         return ret_ref;
14495 }
14496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14497         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
14498         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
14499         return ret_conv;
14500 }
14501
14502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14503         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
14504         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14505         *ret_copy = Bech32Error_clone(orig_conv);
14506         int64_t ret_ref = (uintptr_t)ret_copy;
14507         return ret_ref;
14508 }
14509
14510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
14511         if ((o & 1) != 0) return;
14512         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14513         CHECK_ACCESS(o_ptr);
14514         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
14515         FREE((void*)o);
14516         Bech32Error_free(o_conv);
14517 }
14518
14519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
14520         LDKTransaction _res_ref;
14521         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
14522         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
14523         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
14524         _res_ref.data_is_owned = true;
14525         Transaction_free(_res_ref);
14526 }
14527
14528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
14529         LDKCVec_u8Z script_pubkey_ref;
14530         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
14531         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
14532         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
14533         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14534         *ret_ref = TxOut_new(script_pubkey_ref, value);
14535         return (int64_t)ret_ref;
14536 }
14537
14538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
14539         if ((_res & 1) != 0) return;
14540         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14541         CHECK_ACCESS(_res_ptr);
14542         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
14543         FREE((void*)_res);
14544         TxOut_free(_res_conv);
14545 }
14546
14547 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
14548         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14549         *ret_ref = TxOut_clone(arg);
14550         return (int64_t)ret_ref;
14551 }
14552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14553         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
14554         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
14555         return ret_conv;
14556 }
14557
14558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14559         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
14560         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14561         *ret_ref = TxOut_clone(orig_conv);
14562         return (int64_t)ret_ref;
14563 }
14564
14565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
14566         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
14567         Str_free(dummy);
14568 }
14569
14570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
14571         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14572         *ret_conv = CResult_NoneNoneZ_ok();
14573         return (int64_t)ret_conv;
14574 }
14575
14576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
14577         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14578         *ret_conv = CResult_NoneNoneZ_err();
14579         return (int64_t)ret_conv;
14580 }
14581
14582 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14583         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
14584         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
14585         return ret_conv;
14586 }
14587
14588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14589         if ((_res & 1) != 0) return;
14590         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14591         CHECK_ACCESS(_res_ptr);
14592         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
14593         FREE((void*)_res);
14594         CResult_NoneNoneZ_free(_res_conv);
14595 }
14596
14597 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
14598         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14599         *ret_conv = CResult_NoneNoneZ_clone(arg);
14600         return (int64_t)ret_conv;
14601 }
14602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14603         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
14604         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
14605         return ret_conv;
14606 }
14607
14608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14609         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
14610         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14611         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
14612         return (int64_t)ret_conv;
14613 }
14614
14615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14616         LDKCounterpartyCommitmentSecrets o_conv;
14617         o_conv.inner = (void*)(o & (~1));
14618         o_conv.is_owned = (o & 1) || (o == 0);
14619         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14620         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
14621         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14622         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
14623         return (int64_t)ret_conv;
14624 }
14625
14626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14627         LDKDecodeError e_conv;
14628         e_conv.inner = (void*)(e & (~1));
14629         e_conv.is_owned = (e & 1) || (e == 0);
14630         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14631         e_conv = DecodeError_clone(&e_conv);
14632         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14633         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
14634         return (int64_t)ret_conv;
14635 }
14636
14637 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14638         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
14639         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
14640         return ret_conv;
14641 }
14642
14643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14644         if ((_res & 1) != 0) return;
14645         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14646         CHECK_ACCESS(_res_ptr);
14647         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
14648         FREE((void*)_res);
14649         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
14650 }
14651
14652 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
14653         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14654         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
14655         return (int64_t)ret_conv;
14656 }
14657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14658         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
14659         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
14660         return ret_conv;
14661 }
14662
14663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14664         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
14665         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14666         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
14667         return (int64_t)ret_conv;
14668 }
14669
14670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14671         LDKSecretKey o_ref;
14672         CHECK((*env)->GetArrayLength(env, o) == 32);
14673         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
14674         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14675         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
14676         return (int64_t)ret_conv;
14677 }
14678
14679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14680         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14681         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14682         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
14683         return (int64_t)ret_conv;
14684 }
14685
14686 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14687         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
14688         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
14689         return ret_conv;
14690 }
14691
14692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14693         if ((_res & 1) != 0) return;
14694         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14695         CHECK_ACCESS(_res_ptr);
14696         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
14697         FREE((void*)_res);
14698         CResult_SecretKeyErrorZ_free(_res_conv);
14699 }
14700
14701 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
14702         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14703         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
14704         return (int64_t)ret_conv;
14705 }
14706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14707         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
14708         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
14709         return ret_conv;
14710 }
14711
14712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14713         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
14714         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14715         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
14716         return (int64_t)ret_conv;
14717 }
14718
14719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14720         LDKPublicKey o_ref;
14721         CHECK((*env)->GetArrayLength(env, o) == 33);
14722         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
14723         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14724         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
14725         return (int64_t)ret_conv;
14726 }
14727
14728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14729         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14730         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14731         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
14732         return (int64_t)ret_conv;
14733 }
14734
14735 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14736         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
14737         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
14738         return ret_conv;
14739 }
14740
14741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14742         if ((_res & 1) != 0) return;
14743         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14744         CHECK_ACCESS(_res_ptr);
14745         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
14746         FREE((void*)_res);
14747         CResult_PublicKeyErrorZ_free(_res_conv);
14748 }
14749
14750 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
14751         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14752         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
14753         return (int64_t)ret_conv;
14754 }
14755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14756         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
14757         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
14758         return ret_conv;
14759 }
14760
14761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14762         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
14763         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14764         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
14765         return (int64_t)ret_conv;
14766 }
14767
14768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14769         LDKTxCreationKeys o_conv;
14770         o_conv.inner = (void*)(o & (~1));
14771         o_conv.is_owned = (o & 1) || (o == 0);
14772         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14773         o_conv = TxCreationKeys_clone(&o_conv);
14774         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14775         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
14776         return (int64_t)ret_conv;
14777 }
14778
14779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14780         LDKDecodeError e_conv;
14781         e_conv.inner = (void*)(e & (~1));
14782         e_conv.is_owned = (e & 1) || (e == 0);
14783         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14784         e_conv = DecodeError_clone(&e_conv);
14785         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14786         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
14787         return (int64_t)ret_conv;
14788 }
14789
14790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14791         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
14792         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
14793         return ret_conv;
14794 }
14795
14796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14797         if ((_res & 1) != 0) return;
14798         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14799         CHECK_ACCESS(_res_ptr);
14800         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
14801         FREE((void*)_res);
14802         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
14803 }
14804
14805 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
14806         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14807         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
14808         return (int64_t)ret_conv;
14809 }
14810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14811         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
14812         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
14813         return ret_conv;
14814 }
14815
14816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14817         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
14818         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14819         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
14820         return (int64_t)ret_conv;
14821 }
14822
14823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14824         LDKChannelPublicKeys o_conv;
14825         o_conv.inner = (void*)(o & (~1));
14826         o_conv.is_owned = (o & 1) || (o == 0);
14827         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14828         o_conv = ChannelPublicKeys_clone(&o_conv);
14829         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14830         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
14831         return (int64_t)ret_conv;
14832 }
14833
14834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14835         LDKDecodeError e_conv;
14836         e_conv.inner = (void*)(e & (~1));
14837         e_conv.is_owned = (e & 1) || (e == 0);
14838         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14839         e_conv = DecodeError_clone(&e_conv);
14840         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14841         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
14842         return (int64_t)ret_conv;
14843 }
14844
14845 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14846         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
14847         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
14848         return ret_conv;
14849 }
14850
14851 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14852         if ((_res & 1) != 0) return;
14853         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14854         CHECK_ACCESS(_res_ptr);
14855         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
14856         FREE((void*)_res);
14857         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
14858 }
14859
14860 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
14861         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14862         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
14863         return (int64_t)ret_conv;
14864 }
14865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14866         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
14867         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
14868         return ret_conv;
14869 }
14870
14871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14872         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
14873         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14874         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
14875         return (int64_t)ret_conv;
14876 }
14877
14878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14879         LDKTxCreationKeys o_conv;
14880         o_conv.inner = (void*)(o & (~1));
14881         o_conv.is_owned = (o & 1) || (o == 0);
14882         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14883         o_conv = TxCreationKeys_clone(&o_conv);
14884         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14885         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
14886         return (int64_t)ret_conv;
14887 }
14888
14889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14890         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14891         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14892         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
14893         return (int64_t)ret_conv;
14894 }
14895
14896 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14897         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
14898         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
14899         return ret_conv;
14900 }
14901
14902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14903         if ((_res & 1) != 0) return;
14904         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14905         CHECK_ACCESS(_res_ptr);
14906         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
14907         FREE((void*)_res);
14908         CResult_TxCreationKeysErrorZ_free(_res_conv);
14909 }
14910
14911 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
14912         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14913         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
14914         return (int64_t)ret_conv;
14915 }
14916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14917         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
14918         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
14919         return ret_conv;
14920 }
14921
14922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14923         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
14924         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14925         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
14926         return (int64_t)ret_conv;
14927 }
14928
14929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
14930         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14931         *ret_copy = COption_u32Z_some(o);
14932         int64_t ret_ref = (uintptr_t)ret_copy;
14933         return ret_ref;
14934 }
14935
14936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
14937         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14938         *ret_copy = COption_u32Z_none();
14939         int64_t ret_ref = (uintptr_t)ret_copy;
14940         return ret_ref;
14941 }
14942
14943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14944         if ((_res & 1) != 0) return;
14945         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14946         CHECK_ACCESS(_res_ptr);
14947         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
14948         FREE((void*)_res);
14949         COption_u32Z_free(_res_conv);
14950 }
14951
14952 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
14953         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14954         *ret_copy = COption_u32Z_clone(arg);
14955 int64_t ret_ref = (uintptr_t)ret_copy;
14956         return ret_ref;
14957 }
14958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14959         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
14960         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
14961         return ret_conv;
14962 }
14963
14964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14965         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
14966         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14967         *ret_copy = COption_u32Z_clone(orig_conv);
14968         int64_t ret_ref = (uintptr_t)ret_copy;
14969         return ret_ref;
14970 }
14971
14972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14973         LDKHTLCOutputInCommitment o_conv;
14974         o_conv.inner = (void*)(o & (~1));
14975         o_conv.is_owned = (o & 1) || (o == 0);
14976         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14977         o_conv = HTLCOutputInCommitment_clone(&o_conv);
14978         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14979         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
14980         return (int64_t)ret_conv;
14981 }
14982
14983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14984         LDKDecodeError e_conv;
14985         e_conv.inner = (void*)(e & (~1));
14986         e_conv.is_owned = (e & 1) || (e == 0);
14987         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14988         e_conv = DecodeError_clone(&e_conv);
14989         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14990         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
14991         return (int64_t)ret_conv;
14992 }
14993
14994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14995         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
14996         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
14997         return ret_conv;
14998 }
14999
15000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15001         if ((_res & 1) != 0) return;
15002         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15003         CHECK_ACCESS(_res_ptr);
15004         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
15005         FREE((void*)_res);
15006         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
15007 }
15008
15009 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
15010         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15011         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
15012         return (int64_t)ret_conv;
15013 }
15014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15015         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
15016         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
15017         return ret_conv;
15018 }
15019
15020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15021         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
15022         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15023         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
15024         return (int64_t)ret_conv;
15025 }
15026
15027 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
15028         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
15029         return ret_conv;
15030 }
15031
15032 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
15033         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
15034         return ret_conv;
15035 }
15036
15037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
15038         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
15039         COption_NoneZ_free(_res_conv);
15040 }
15041
15042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15043         LDKCounterpartyChannelTransactionParameters o_conv;
15044         o_conv.inner = (void*)(o & (~1));
15045         o_conv.is_owned = (o & 1) || (o == 0);
15046         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15047         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
15048         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15049         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15050         return (int64_t)ret_conv;
15051 }
15052
15053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15054         LDKDecodeError e_conv;
15055         e_conv.inner = (void*)(e & (~1));
15056         e_conv.is_owned = (e & 1) || (e == 0);
15057         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15058         e_conv = DecodeError_clone(&e_conv);
15059         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15060         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
15061         return (int64_t)ret_conv;
15062 }
15063
15064 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15065         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
15066         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15067         return ret_conv;
15068 }
15069
15070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15071         if ((_res & 1) != 0) return;
15072         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15073         CHECK_ACCESS(_res_ptr);
15074         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15075         FREE((void*)_res);
15076         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15077 }
15078
15079 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15080         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15081         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
15082         return (int64_t)ret_conv;
15083 }
15084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15085         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
15086         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15087         return ret_conv;
15088 }
15089
15090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15091         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
15092         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15093         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15094         return (int64_t)ret_conv;
15095 }
15096
15097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15098         LDKChannelTransactionParameters o_conv;
15099         o_conv.inner = (void*)(o & (~1));
15100         o_conv.is_owned = (o & 1) || (o == 0);
15101         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15102         o_conv = ChannelTransactionParameters_clone(&o_conv);
15103         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15104         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15105         return (int64_t)ret_conv;
15106 }
15107
15108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15109         LDKDecodeError e_conv;
15110         e_conv.inner = (void*)(e & (~1));
15111         e_conv.is_owned = (e & 1) || (e == 0);
15112         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15113         e_conv = DecodeError_clone(&e_conv);
15114         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15115         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
15116         return (int64_t)ret_conv;
15117 }
15118
15119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15120         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
15121         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15122         return ret_conv;
15123 }
15124
15125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15126         if ((_res & 1) != 0) return;
15127         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15128         CHECK_ACCESS(_res_ptr);
15129         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15130         FREE((void*)_res);
15131         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15132 }
15133
15134 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15135         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15136         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
15137         return (int64_t)ret_conv;
15138 }
15139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15140         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
15141         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15142         return ret_conv;
15143 }
15144
15145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15146         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
15147         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15148         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15149         return (int64_t)ret_conv;
15150 }
15151
15152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15153         LDKCVec_SignatureZ _res_constr;
15154         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15155         if (_res_constr.datalen > 0)
15156                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15157         else
15158                 _res_constr.data = NULL;
15159         for (size_t i = 0; i < _res_constr.datalen; i++) {
15160                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15161                 LDKSignature _res_conv_8_ref;
15162                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
15163                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
15164                 _res_constr.data[i] = _res_conv_8_ref;
15165         }
15166         CVec_SignatureZ_free(_res_constr);
15167 }
15168
15169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15170         LDKHolderCommitmentTransaction o_conv;
15171         o_conv.inner = (void*)(o & (~1));
15172         o_conv.is_owned = (o & 1) || (o == 0);
15173         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15174         o_conv = HolderCommitmentTransaction_clone(&o_conv);
15175         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15176         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
15177         return (int64_t)ret_conv;
15178 }
15179
15180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15181         LDKDecodeError e_conv;
15182         e_conv.inner = (void*)(e & (~1));
15183         e_conv.is_owned = (e & 1) || (e == 0);
15184         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15185         e_conv = DecodeError_clone(&e_conv);
15186         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15187         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
15188         return (int64_t)ret_conv;
15189 }
15190
15191 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15192         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
15193         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15194         return ret_conv;
15195 }
15196
15197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15198         if ((_res & 1) != 0) return;
15199         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15200         CHECK_ACCESS(_res_ptr);
15201         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15202         FREE((void*)_res);
15203         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
15204 }
15205
15206 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15207         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15208         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
15209         return (int64_t)ret_conv;
15210 }
15211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15212         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15213         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15214         return ret_conv;
15215 }
15216
15217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15218         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15219         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15220         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15221         return (int64_t)ret_conv;
15222 }
15223
15224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15225         LDKBuiltCommitmentTransaction o_conv;
15226         o_conv.inner = (void*)(o & (~1));
15227         o_conv.is_owned = (o & 1) || (o == 0);
15228         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15229         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
15230         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15231         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
15232         return (int64_t)ret_conv;
15233 }
15234
15235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15236         LDKDecodeError e_conv;
15237         e_conv.inner = (void*)(e & (~1));
15238         e_conv.is_owned = (e & 1) || (e == 0);
15239         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15240         e_conv = DecodeError_clone(&e_conv);
15241         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15242         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
15243         return (int64_t)ret_conv;
15244 }
15245
15246 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15247         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
15248         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15249         return ret_conv;
15250 }
15251
15252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15253         if ((_res & 1) != 0) return;
15254         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15255         CHECK_ACCESS(_res_ptr);
15256         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15257         FREE((void*)_res);
15258         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
15259 }
15260
15261 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15262         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15263         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
15264         return (int64_t)ret_conv;
15265 }
15266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15267         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
15268         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15269         return ret_conv;
15270 }
15271
15272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15273         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
15274         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15275         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15276         return (int64_t)ret_conv;
15277 }
15278
15279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15280         LDKTrustedClosingTransaction o_conv;
15281         o_conv.inner = (void*)(o & (~1));
15282         o_conv.is_owned = (o & 1) || (o == 0);
15283         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15284         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
15285         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15286         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
15287         return (int64_t)ret_conv;
15288 }
15289
15290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15291         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15292         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
15293         return (int64_t)ret_conv;
15294 }
15295
15296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15297         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
15298         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
15299         return ret_conv;
15300 }
15301
15302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15303         if ((_res & 1) != 0) return;
15304         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15305         CHECK_ACCESS(_res_ptr);
15306         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
15307         FREE((void*)_res);
15308         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
15309 }
15310
15311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15312         LDKCommitmentTransaction o_conv;
15313         o_conv.inner = (void*)(o & (~1));
15314         o_conv.is_owned = (o & 1) || (o == 0);
15315         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15316         o_conv = CommitmentTransaction_clone(&o_conv);
15317         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15318         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
15319         return (int64_t)ret_conv;
15320 }
15321
15322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15323         LDKDecodeError e_conv;
15324         e_conv.inner = (void*)(e & (~1));
15325         e_conv.is_owned = (e & 1) || (e == 0);
15326         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15327         e_conv = DecodeError_clone(&e_conv);
15328         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15329         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
15330         return (int64_t)ret_conv;
15331 }
15332
15333 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15334         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
15335         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15336         return ret_conv;
15337 }
15338
15339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15340         if ((_res & 1) != 0) return;
15341         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15342         CHECK_ACCESS(_res_ptr);
15343         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
15344         FREE((void*)_res);
15345         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
15346 }
15347
15348 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15349         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15350         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
15351         return (int64_t)ret_conv;
15352 }
15353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15354         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
15355         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15356         return ret_conv;
15357 }
15358
15359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15360         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
15361         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
15362         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
15363         return (int64_t)ret_conv;
15364 }
15365
15366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15367         LDKTrustedCommitmentTransaction o_conv;
15368         o_conv.inner = (void*)(o & (~1));
15369         o_conv.is_owned = (o & 1) || (o == 0);
15370         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15371         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
15372         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15373         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
15374         return (int64_t)ret_conv;
15375 }
15376
15377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15378         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
15379         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
15380         return (int64_t)ret_conv;
15381 }
15382
15383 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15384         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
15385         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
15386         return ret_conv;
15387 }
15388
15389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15390         if ((_res & 1) != 0) return;
15391         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15392         CHECK_ACCESS(_res_ptr);
15393         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
15394         FREE((void*)_res);
15395         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
15396 }
15397
15398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
15399         LDKCVec_SignatureZ o_constr;
15400         o_constr.datalen = (*env)->GetArrayLength(env, o);
15401         if (o_constr.datalen > 0)
15402                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15403         else
15404                 o_constr.data = NULL;
15405         for (size_t i = 0; i < o_constr.datalen; i++) {
15406                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
15407                 LDKSignature o_conv_8_ref;
15408                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
15409                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
15410                 o_constr.data[i] = o_conv_8_ref;
15411         }
15412         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15413         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
15414         return (int64_t)ret_conv;
15415 }
15416
15417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
15418         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15419         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
15420         return (int64_t)ret_conv;
15421 }
15422
15423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15424         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
15425         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
15426         return ret_conv;
15427 }
15428
15429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15430         if ((_res & 1) != 0) return;
15431         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15432         CHECK_ACCESS(_res_ptr);
15433         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
15434         FREE((void*)_res);
15435         CResult_CVec_SignatureZNoneZ_free(_res_conv);
15436 }
15437
15438 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
15439         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15440         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
15441         return (int64_t)ret_conv;
15442 }
15443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15444         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
15445         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
15446         return ret_conv;
15447 }
15448
15449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15450         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
15451         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15452         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
15453         return (int64_t)ret_conv;
15454 }
15455
15456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15457         LDKShutdownScript o_conv;
15458         o_conv.inner = (void*)(o & (~1));
15459         o_conv.is_owned = (o & 1) || (o == 0);
15460         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15461         o_conv = ShutdownScript_clone(&o_conv);
15462         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15463         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
15464         return (int64_t)ret_conv;
15465 }
15466
15467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15468         LDKDecodeError e_conv;
15469         e_conv.inner = (void*)(e & (~1));
15470         e_conv.is_owned = (e & 1) || (e == 0);
15471         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15472         e_conv = DecodeError_clone(&e_conv);
15473         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15474         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
15475         return (int64_t)ret_conv;
15476 }
15477
15478 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15479         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
15480         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
15481         return ret_conv;
15482 }
15483
15484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15485         if ((_res & 1) != 0) return;
15486         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15487         CHECK_ACCESS(_res_ptr);
15488         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
15489         FREE((void*)_res);
15490         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
15491 }
15492
15493 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
15494         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15495         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
15496         return (int64_t)ret_conv;
15497 }
15498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15499         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
15500         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
15501         return ret_conv;
15502 }
15503
15504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15505         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
15506         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15507         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
15508         return (int64_t)ret_conv;
15509 }
15510
15511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15512         LDKShutdownScript o_conv;
15513         o_conv.inner = (void*)(o & (~1));
15514         o_conv.is_owned = (o & 1) || (o == 0);
15515         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15516         o_conv = ShutdownScript_clone(&o_conv);
15517         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15518         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
15519         return (int64_t)ret_conv;
15520 }
15521
15522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15523         LDKInvalidShutdownScript e_conv;
15524         e_conv.inner = (void*)(e & (~1));
15525         e_conv.is_owned = (e & 1) || (e == 0);
15526         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15527         e_conv = InvalidShutdownScript_clone(&e_conv);
15528         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15529         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
15530         return (int64_t)ret_conv;
15531 }
15532
15533 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15534         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
15535         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
15536         return ret_conv;
15537 }
15538
15539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15540         if ((_res & 1) != 0) return;
15541         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15542         CHECK_ACCESS(_res_ptr);
15543         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
15544         FREE((void*)_res);
15545         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
15546 }
15547
15548 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
15549         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15550         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
15551         return (int64_t)ret_conv;
15552 }
15553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15554         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
15555         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
15556         return ret_conv;
15557 }
15558
15559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15560         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
15561         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15562         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
15563         return (int64_t)ret_conv;
15564 }
15565
15566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
15567         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15568         *ret_conv = CResult_NoneErrorZ_ok();
15569         return (int64_t)ret_conv;
15570 }
15571
15572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15573         LDKIOError e_conv = LDKIOError_from_java(env, e);
15574         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15575         *ret_conv = CResult_NoneErrorZ_err(e_conv);
15576         return (int64_t)ret_conv;
15577 }
15578
15579 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15580         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
15581         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
15582         return ret_conv;
15583 }
15584
15585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15586         if ((_res & 1) != 0) return;
15587         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15588         CHECK_ACCESS(_res_ptr);
15589         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
15590         FREE((void*)_res);
15591         CResult_NoneErrorZ_free(_res_conv);
15592 }
15593
15594 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
15595         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15596         *ret_conv = CResult_NoneErrorZ_clone(arg);
15597         return (int64_t)ret_conv;
15598 }
15599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15600         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
15601         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
15602         return ret_conv;
15603 }
15604
15605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15606         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
15607         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15608         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
15609         return (int64_t)ret_conv;
15610 }
15611
15612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15613         LDKRouteHop o_conv;
15614         o_conv.inner = (void*)(o & (~1));
15615         o_conv.is_owned = (o & 1) || (o == 0);
15616         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15617         o_conv = RouteHop_clone(&o_conv);
15618         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15619         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
15620         return (int64_t)ret_conv;
15621 }
15622
15623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15624         LDKDecodeError e_conv;
15625         e_conv.inner = (void*)(e & (~1));
15626         e_conv.is_owned = (e & 1) || (e == 0);
15627         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15628         e_conv = DecodeError_clone(&e_conv);
15629         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15630         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
15631         return (int64_t)ret_conv;
15632 }
15633
15634 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15635         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
15636         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
15637         return ret_conv;
15638 }
15639
15640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15641         if ((_res & 1) != 0) return;
15642         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15643         CHECK_ACCESS(_res_ptr);
15644         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
15645         FREE((void*)_res);
15646         CResult_RouteHopDecodeErrorZ_free(_res_conv);
15647 }
15648
15649 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
15650         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15651         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
15652         return (int64_t)ret_conv;
15653 }
15654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15655         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
15656         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
15657         return ret_conv;
15658 }
15659
15660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15661         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
15662         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15663         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
15664         return (int64_t)ret_conv;
15665 }
15666
15667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15668         LDKCVec_RouteHopZ _res_constr;
15669         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15670         if (_res_constr.datalen > 0)
15671                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15672         else
15673                 _res_constr.data = NULL;
15674         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15675         for (size_t k = 0; k < _res_constr.datalen; k++) {
15676                 int64_t _res_conv_10 = _res_vals[k];
15677                 LDKRouteHop _res_conv_10_conv;
15678                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15679                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15680                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
15681                 _res_constr.data[k] = _res_conv_10_conv;
15682         }
15683         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15684         CVec_RouteHopZ_free(_res_constr);
15685 }
15686
15687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15688         LDKCVec_CVec_RouteHopZZ _res_constr;
15689         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15690         if (_res_constr.datalen > 0)
15691                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
15692         else
15693                 _res_constr.data = NULL;
15694         for (size_t m = 0; m < _res_constr.datalen; m++) {
15695                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
15696                 LDKCVec_RouteHopZ _res_conv_12_constr;
15697                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
15698                 if (_res_conv_12_constr.datalen > 0)
15699                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15700                 else
15701                         _res_conv_12_constr.data = NULL;
15702                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
15703                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
15704                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
15705                         LDKRouteHop _res_conv_12_conv_10_conv;
15706                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
15707                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
15708                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
15709                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
15710                 }
15711                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
15712                 _res_constr.data[m] = _res_conv_12_constr;
15713         }
15714         CVec_CVec_RouteHopZZ_free(_res_constr);
15715 }
15716
15717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15718         LDKRoute o_conv;
15719         o_conv.inner = (void*)(o & (~1));
15720         o_conv.is_owned = (o & 1) || (o == 0);
15721         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15722         o_conv = Route_clone(&o_conv);
15723         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15724         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
15725         return (int64_t)ret_conv;
15726 }
15727
15728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15729         LDKDecodeError e_conv;
15730         e_conv.inner = (void*)(e & (~1));
15731         e_conv.is_owned = (e & 1) || (e == 0);
15732         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15733         e_conv = DecodeError_clone(&e_conv);
15734         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15735         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
15736         return (int64_t)ret_conv;
15737 }
15738
15739 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15740         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
15741         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
15742         return ret_conv;
15743 }
15744
15745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15746         if ((_res & 1) != 0) return;
15747         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15748         CHECK_ACCESS(_res_ptr);
15749         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
15750         FREE((void*)_res);
15751         CResult_RouteDecodeErrorZ_free(_res_conv);
15752 }
15753
15754 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
15755         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15756         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
15757         return (int64_t)ret_conv;
15758 }
15759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15760         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
15761         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
15762         return ret_conv;
15763 }
15764
15765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15766         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
15767         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15768         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
15769         return (int64_t)ret_conv;
15770 }
15771
15772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15773         LDKRouteParameters o_conv;
15774         o_conv.inner = (void*)(o & (~1));
15775         o_conv.is_owned = (o & 1) || (o == 0);
15776         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15777         o_conv = RouteParameters_clone(&o_conv);
15778         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15779         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
15780         return (int64_t)ret_conv;
15781 }
15782
15783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15784         LDKDecodeError e_conv;
15785         e_conv.inner = (void*)(e & (~1));
15786         e_conv.is_owned = (e & 1) || (e == 0);
15787         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15788         e_conv = DecodeError_clone(&e_conv);
15789         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15790         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
15791         return (int64_t)ret_conv;
15792 }
15793
15794 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15795         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
15796         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
15797         return ret_conv;
15798 }
15799
15800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15801         if ((_res & 1) != 0) return;
15802         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15803         CHECK_ACCESS(_res_ptr);
15804         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
15805         FREE((void*)_res);
15806         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
15807 }
15808
15809 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
15810         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15811         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
15812         return (int64_t)ret_conv;
15813 }
15814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15815         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
15816         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
15817         return ret_conv;
15818 }
15819
15820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15821         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
15822         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15823         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
15824         return (int64_t)ret_conv;
15825 }
15826
15827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15828         LDKCVec_RouteHintZ _res_constr;
15829         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15830         if (_res_constr.datalen > 0)
15831                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
15832         else
15833                 _res_constr.data = NULL;
15834         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15835         for (size_t l = 0; l < _res_constr.datalen; l++) {
15836                 int64_t _res_conv_11 = _res_vals[l];
15837                 LDKRouteHint _res_conv_11_conv;
15838                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
15839                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
15840                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
15841                 _res_constr.data[l] = _res_conv_11_conv;
15842         }
15843         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15844         CVec_RouteHintZ_free(_res_constr);
15845 }
15846
15847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
15848         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15849         *ret_copy = COption_u64Z_some(o);
15850         int64_t ret_ref = (uintptr_t)ret_copy;
15851         return ret_ref;
15852 }
15853
15854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
15855         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15856         *ret_copy = COption_u64Z_none();
15857         int64_t ret_ref = (uintptr_t)ret_copy;
15858         return ret_ref;
15859 }
15860
15861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15862         if ((_res & 1) != 0) return;
15863         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15864         CHECK_ACCESS(_res_ptr);
15865         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
15866         FREE((void*)_res);
15867         COption_u64Z_free(_res_conv);
15868 }
15869
15870 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
15871         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15872         *ret_copy = COption_u64Z_clone(arg);
15873 int64_t ret_ref = (uintptr_t)ret_copy;
15874         return ret_ref;
15875 }
15876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15877         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
15878         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
15879         return ret_conv;
15880 }
15881
15882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15883         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
15884         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15885         *ret_copy = COption_u64Z_clone(orig_conv);
15886         int64_t ret_ref = (uintptr_t)ret_copy;
15887         return ret_ref;
15888 }
15889
15890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15891         LDKPaymentParameters o_conv;
15892         o_conv.inner = (void*)(o & (~1));
15893         o_conv.is_owned = (o & 1) || (o == 0);
15894         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15895         o_conv = PaymentParameters_clone(&o_conv);
15896         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15897         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
15898         return (int64_t)ret_conv;
15899 }
15900
15901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15902         LDKDecodeError e_conv;
15903         e_conv.inner = (void*)(e & (~1));
15904         e_conv.is_owned = (e & 1) || (e == 0);
15905         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15906         e_conv = DecodeError_clone(&e_conv);
15907         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15908         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
15909         return (int64_t)ret_conv;
15910 }
15911
15912 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15913         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
15914         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
15915         return ret_conv;
15916 }
15917
15918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15919         if ((_res & 1) != 0) return;
15920         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15921         CHECK_ACCESS(_res_ptr);
15922         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
15923         FREE((void*)_res);
15924         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
15925 }
15926
15927 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
15928         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15929         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
15930         return (int64_t)ret_conv;
15931 }
15932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15933         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
15934         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
15935         return ret_conv;
15936 }
15937
15938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15939         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
15940         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15941         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
15942         return (int64_t)ret_conv;
15943 }
15944
15945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15946         LDKCVec_RouteHintHopZ _res_constr;
15947         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15948         if (_res_constr.datalen > 0)
15949                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
15950         else
15951                 _res_constr.data = NULL;
15952         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15953         for (size_t o = 0; o < _res_constr.datalen; o++) {
15954                 int64_t _res_conv_14 = _res_vals[o];
15955                 LDKRouteHintHop _res_conv_14_conv;
15956                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15957                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15958                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15959                 _res_constr.data[o] = _res_conv_14_conv;
15960         }
15961         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15962         CVec_RouteHintHopZ_free(_res_constr);
15963 }
15964
15965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15966         LDKRouteHint o_conv;
15967         o_conv.inner = (void*)(o & (~1));
15968         o_conv.is_owned = (o & 1) || (o == 0);
15969         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15970         o_conv = RouteHint_clone(&o_conv);
15971         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15972         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
15973         return (int64_t)ret_conv;
15974 }
15975
15976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15977         LDKDecodeError e_conv;
15978         e_conv.inner = (void*)(e & (~1));
15979         e_conv.is_owned = (e & 1) || (e == 0);
15980         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15981         e_conv = DecodeError_clone(&e_conv);
15982         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15983         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
15984         return (int64_t)ret_conv;
15985 }
15986
15987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15988         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
15989         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
15990         return ret_conv;
15991 }
15992
15993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15994         if ((_res & 1) != 0) return;
15995         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15996         CHECK_ACCESS(_res_ptr);
15997         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
15998         FREE((void*)_res);
15999         CResult_RouteHintDecodeErrorZ_free(_res_conv);
16000 }
16001
16002 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
16003         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16004         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
16005         return (int64_t)ret_conv;
16006 }
16007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16008         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
16009         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
16010         return ret_conv;
16011 }
16012
16013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16014         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
16015         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16016         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
16017         return (int64_t)ret_conv;
16018 }
16019
16020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16021         LDKRouteHintHop o_conv;
16022         o_conv.inner = (void*)(o & (~1));
16023         o_conv.is_owned = (o & 1) || (o == 0);
16024         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16025         o_conv = RouteHintHop_clone(&o_conv);
16026         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16027         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
16028         return (int64_t)ret_conv;
16029 }
16030
16031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16032         LDKDecodeError e_conv;
16033         e_conv.inner = (void*)(e & (~1));
16034         e_conv.is_owned = (e & 1) || (e == 0);
16035         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16036         e_conv = DecodeError_clone(&e_conv);
16037         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16038         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
16039         return (int64_t)ret_conv;
16040 }
16041
16042 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16043         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
16044         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
16045         return ret_conv;
16046 }
16047
16048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16049         if ((_res & 1) != 0) return;
16050         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16051         CHECK_ACCESS(_res_ptr);
16052         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
16053         FREE((void*)_res);
16054         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
16055 }
16056
16057 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
16058         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16059         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
16060         return (int64_t)ret_conv;
16061 }
16062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16063         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
16064         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
16065         return ret_conv;
16066 }
16067
16068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16069         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
16070         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16071         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
16072         return (int64_t)ret_conv;
16073 }
16074
16075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16076         LDKCVec_ChannelDetailsZ _res_constr;
16077         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16078         if (_res_constr.datalen > 0)
16079                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
16080         else
16081                 _res_constr.data = NULL;
16082         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16083         for (size_t q = 0; q < _res_constr.datalen; q++) {
16084                 int64_t _res_conv_16 = _res_vals[q];
16085                 LDKChannelDetails _res_conv_16_conv;
16086                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16087                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16088                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16089                 _res_constr.data[q] = _res_conv_16_conv;
16090         }
16091         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16092         CVec_ChannelDetailsZ_free(_res_constr);
16093 }
16094
16095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16096         LDKRoute o_conv;
16097         o_conv.inner = (void*)(o & (~1));
16098         o_conv.is_owned = (o & 1) || (o == 0);
16099         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16100         o_conv = Route_clone(&o_conv);
16101         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16102         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
16103         return (int64_t)ret_conv;
16104 }
16105
16106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16107         LDKLightningError e_conv;
16108         e_conv.inner = (void*)(e & (~1));
16109         e_conv.is_owned = (e & 1) || (e == 0);
16110         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16111         e_conv = LightningError_clone(&e_conv);
16112         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16113         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
16114         return (int64_t)ret_conv;
16115 }
16116
16117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16118         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
16119         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
16120         return ret_conv;
16121 }
16122
16123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16124         if ((_res & 1) != 0) return;
16125         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16126         CHECK_ACCESS(_res_ptr);
16127         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
16128         FREE((void*)_res);
16129         CResult_RouteLightningErrorZ_free(_res_conv);
16130 }
16131
16132 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
16133         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16134         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
16135         return (int64_t)ret_conv;
16136 }
16137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16138         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
16139         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
16140         return ret_conv;
16141 }
16142
16143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16144         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
16145         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16146         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
16147         return (int64_t)ret_conv;
16148 }
16149
16150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16151         LDKCVec_PublicKeyZ _res_constr;
16152         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16153         if (_res_constr.datalen > 0)
16154                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16155         else
16156                 _res_constr.data = NULL;
16157         for (size_t i = 0; i < _res_constr.datalen; i++) {
16158                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16159                 LDKPublicKey _res_conv_8_ref;
16160                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
16161                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
16162                 _res_constr.data[i] = _res_conv_8_ref;
16163         }
16164         CVec_PublicKeyZ_free(_res_constr);
16165 }
16166
16167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16168         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16169         CHECK_ACCESS(o_ptr);
16170         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
16171         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
16172         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16173         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
16174         return (int64_t)ret_conv;
16175 }
16176
16177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16178         LDKDecodeError e_conv;
16179         e_conv.inner = (void*)(e & (~1));
16180         e_conv.is_owned = (e & 1) || (e == 0);
16181         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16182         e_conv = DecodeError_clone(&e_conv);
16183         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16184         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
16185         return (int64_t)ret_conv;
16186 }
16187
16188 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16189         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
16190         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
16191         return ret_conv;
16192 }
16193
16194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16195         if ((_res & 1) != 0) return;
16196         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16197         CHECK_ACCESS(_res_ptr);
16198         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
16199         FREE((void*)_res);
16200         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
16201 }
16202
16203 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
16204         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16205         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
16206         return (int64_t)ret_conv;
16207 }
16208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16209         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
16210         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
16211         return ret_conv;
16212 }
16213
16214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16215         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
16216         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16217         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
16218         return (int64_t)ret_conv;
16219 }
16220
16221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16222         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16223         CHECK_ACCESS(o_ptr);
16224         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
16225         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
16226         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16227         *ret_copy = COption_ClosureReasonZ_some(o_conv);
16228         int64_t ret_ref = (uintptr_t)ret_copy;
16229         return ret_ref;
16230 }
16231
16232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
16233         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16234         *ret_copy = COption_ClosureReasonZ_none();
16235         int64_t ret_ref = (uintptr_t)ret_copy;
16236         return ret_ref;
16237 }
16238
16239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16240         if ((_res & 1) != 0) return;
16241         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16242         CHECK_ACCESS(_res_ptr);
16243         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
16244         FREE((void*)_res);
16245         COption_ClosureReasonZ_free(_res_conv);
16246 }
16247
16248 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
16249         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16250         *ret_copy = COption_ClosureReasonZ_clone(arg);
16251 int64_t ret_ref = (uintptr_t)ret_copy;
16252         return ret_ref;
16253 }
16254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16255         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
16256         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
16257         return ret_conv;
16258 }
16259
16260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16261         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
16262         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16263         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
16264         int64_t ret_ref = (uintptr_t)ret_copy;
16265         return ret_ref;
16266 }
16267
16268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16269         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16270         CHECK_ACCESS(o_ptr);
16271         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
16272         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
16273         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16274         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
16275         return (int64_t)ret_conv;
16276 }
16277
16278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16279         LDKDecodeError e_conv;
16280         e_conv.inner = (void*)(e & (~1));
16281         e_conv.is_owned = (e & 1) || (e == 0);
16282         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16283         e_conv = DecodeError_clone(&e_conv);
16284         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16285         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
16286         return (int64_t)ret_conv;
16287 }
16288
16289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16290         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
16291         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
16292         return ret_conv;
16293 }
16294
16295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16296         if ((_res & 1) != 0) return;
16297         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16298         CHECK_ACCESS(_res_ptr);
16299         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
16300         FREE((void*)_res);
16301         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
16302 }
16303
16304 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
16305         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16306         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
16307         return (int64_t)ret_conv;
16308 }
16309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16310         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
16311         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
16312         return ret_conv;
16313 }
16314
16315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16316         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
16317         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16318         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
16319         return (int64_t)ret_conv;
16320 }
16321
16322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16323         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16324         CHECK_ACCESS(o_ptr);
16325         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
16326         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
16327         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16328         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
16329         int64_t ret_ref = (uintptr_t)ret_copy;
16330         return ret_ref;
16331 }
16332
16333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
16334         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16335         *ret_copy = COption_NetworkUpdateZ_none();
16336         int64_t ret_ref = (uintptr_t)ret_copy;
16337         return ret_ref;
16338 }
16339
16340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16341         if ((_res & 1) != 0) return;
16342         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16343         CHECK_ACCESS(_res_ptr);
16344         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
16345         FREE((void*)_res);
16346         COption_NetworkUpdateZ_free(_res_conv);
16347 }
16348
16349 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
16350         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16351         *ret_copy = COption_NetworkUpdateZ_clone(arg);
16352 int64_t ret_ref = (uintptr_t)ret_copy;
16353         return ret_ref;
16354 }
16355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16356         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
16357         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
16358         return ret_conv;
16359 }
16360
16361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16362         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
16363         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16364         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
16365         int64_t ret_ref = (uintptr_t)ret_copy;
16366         return ret_ref;
16367 }
16368
16369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16370         LDKCVec_SpendableOutputDescriptorZ _res_constr;
16371         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16372         if (_res_constr.datalen > 0)
16373                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16374         else
16375                 _res_constr.data = NULL;
16376         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16377         for (size_t b = 0; b < _res_constr.datalen; b++) {
16378                 int64_t _res_conv_27 = _res_vals[b];
16379                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
16380                 CHECK_ACCESS(_res_conv_27_ptr);
16381                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
16382                 FREE((void*)_res_conv_27);
16383                 _res_constr.data[b] = _res_conv_27_conv;
16384         }
16385         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16386         CVec_SpendableOutputDescriptorZ_free(_res_constr);
16387 }
16388
16389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16390         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16391         CHECK_ACCESS(o_ptr);
16392         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
16393         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
16394         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16395         *ret_copy = COption_EventZ_some(o_conv);
16396         int64_t ret_ref = (uintptr_t)ret_copy;
16397         return ret_ref;
16398 }
16399
16400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
16401         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16402         *ret_copy = COption_EventZ_none();
16403         int64_t ret_ref = (uintptr_t)ret_copy;
16404         return ret_ref;
16405 }
16406
16407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16408         if ((_res & 1) != 0) return;
16409         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16410         CHECK_ACCESS(_res_ptr);
16411         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
16412         FREE((void*)_res);
16413         COption_EventZ_free(_res_conv);
16414 }
16415
16416 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
16417         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16418         *ret_copy = COption_EventZ_clone(arg);
16419 int64_t ret_ref = (uintptr_t)ret_copy;
16420         return ret_ref;
16421 }
16422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16423         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
16424         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
16425         return ret_conv;
16426 }
16427
16428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16429         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
16430         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16431         *ret_copy = COption_EventZ_clone(orig_conv);
16432         int64_t ret_ref = (uintptr_t)ret_copy;
16433         return ret_ref;
16434 }
16435
16436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16437         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16438         CHECK_ACCESS(o_ptr);
16439         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
16440         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
16441         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16442         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
16443         return (int64_t)ret_conv;
16444 }
16445
16446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16447         LDKDecodeError e_conv;
16448         e_conv.inner = (void*)(e & (~1));
16449         e_conv.is_owned = (e & 1) || (e == 0);
16450         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16451         e_conv = DecodeError_clone(&e_conv);
16452         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16453         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
16454         return (int64_t)ret_conv;
16455 }
16456
16457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16458         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
16459         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
16460         return ret_conv;
16461 }
16462
16463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16464         if ((_res & 1) != 0) return;
16465         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16466         CHECK_ACCESS(_res_ptr);
16467         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
16468         FREE((void*)_res);
16469         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
16470 }
16471
16472 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
16473         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16474         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
16475         return (int64_t)ret_conv;
16476 }
16477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16478         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
16479         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
16480         return ret_conv;
16481 }
16482
16483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16484         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
16485         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16486         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
16487         return (int64_t)ret_conv;
16488 }
16489
16490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16491         LDKCVec_MessageSendEventZ _res_constr;
16492         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16493         if (_res_constr.datalen > 0)
16494                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
16495         else
16496                 _res_constr.data = NULL;
16497         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16498         for (size_t s = 0; s < _res_constr.datalen; s++) {
16499                 int64_t _res_conv_18 = _res_vals[s];
16500                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
16501                 CHECK_ACCESS(_res_conv_18_ptr);
16502                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
16503                 FREE((void*)_res_conv_18);
16504                 _res_constr.data[s] = _res_conv_18_conv;
16505         }
16506         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16507         CVec_MessageSendEventZ_free(_res_constr);
16508 }
16509
16510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16511         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16512         CHECK_ACCESS(o_ptr);
16513         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
16514         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
16515         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16516         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
16517         return (int64_t)ret_conv;
16518 }
16519
16520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16521         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
16522         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16523         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
16524         return (int64_t)ret_conv;
16525 }
16526
16527 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16528         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
16529         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
16530         return ret_conv;
16531 }
16532
16533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16534         if ((_res & 1) != 0) return;
16535         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16536         CHECK_ACCESS(_res_ptr);
16537         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
16538         FREE((void*)_res);
16539         CResult_TxOutAccessErrorZ_free(_res_conv);
16540 }
16541
16542 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
16543         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16544         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
16545         return (int64_t)ret_conv;
16546 }
16547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16548         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
16549         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
16550         return ret_conv;
16551 }
16552
16553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16554         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
16555         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
16556         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
16557         return (int64_t)ret_conv;
16558 }
16559
16560 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
16561         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
16562         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
16563         return ((int64_t)ret_conv);
16564 }
16565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16566         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
16567         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
16568         return ret_conv;
16569 }
16570
16571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16572         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
16573         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
16574         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
16575         return ((int64_t)ret_conv);
16576 }
16577
16578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
16579         LDKTransaction b_ref;
16580         b_ref.datalen = (*env)->GetArrayLength(env, b);
16581         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
16582         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
16583         b_ref.data_is_owned = true;
16584         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
16585         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
16586         return ((int64_t)ret_conv);
16587 }
16588
16589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_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         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
16594         FREE((void*)_res);
16595         C2Tuple_usizeTransactionZ_free(_res_conv);
16596 }
16597
16598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16599         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
16600         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16601         if (_res_constr.datalen > 0)
16602                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
16603         else
16604                 _res_constr.data = NULL;
16605         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16606         for (size_t c = 0; c < _res_constr.datalen; c++) {
16607                 int64_t _res_conv_28 = _res_vals[c];
16608                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
16609                 CHECK_ACCESS(_res_conv_28_ptr);
16610                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
16611                 FREE((void*)_res_conv_28);
16612                 _res_constr.data[c] = _res_conv_28_conv;
16613         }
16614         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16615         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
16616 }
16617
16618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16619         LDKCVec_TxidZ _res_constr;
16620         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16621         if (_res_constr.datalen > 0)
16622                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
16623         else
16624                 _res_constr.data = NULL;
16625         for (size_t i = 0; i < _res_constr.datalen; i++) {
16626                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16627                 LDKThirtyTwoBytes _res_conv_8_ref;
16628                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
16629                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
16630                 _res_constr.data[i] = _res_conv_8_ref;
16631         }
16632         CVec_TxidZ_free(_res_constr);
16633 }
16634
16635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
16636         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16637         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
16638         return (int64_t)ret_conv;
16639 }
16640
16641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
16642         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
16643         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16644         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
16645         return (int64_t)ret_conv;
16646 }
16647
16648 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16649         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
16650         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
16651         return ret_conv;
16652 }
16653
16654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16655         if ((_res & 1) != 0) return;
16656         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16657         CHECK_ACCESS(_res_ptr);
16658         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
16659         FREE((void*)_res);
16660         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
16661 }
16662
16663 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
16664         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16665         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
16666         return (int64_t)ret_conv;
16667 }
16668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16669         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
16670         int64_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
16671         return ret_conv;
16672 }
16673
16674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16675         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
16676         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
16677         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
16678         return (int64_t)ret_conv;
16679 }
16680
16681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16682         LDKCVec_MonitorEventZ _res_constr;
16683         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16684         if (_res_constr.datalen > 0)
16685                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
16686         else
16687                 _res_constr.data = NULL;
16688         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16689         for (size_t o = 0; o < _res_constr.datalen; o++) {
16690                 int64_t _res_conv_14 = _res_vals[o];
16691                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
16692                 CHECK_ACCESS(_res_conv_14_ptr);
16693                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
16694                 FREE((void*)_res_conv_14);
16695                 _res_constr.data[o] = _res_conv_14_conv;
16696         }
16697         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16698         CVec_MonitorEventZ_free(_res_constr);
16699 }
16700
16701 static inline uintptr_t C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR arg) {
16702         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
16703         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(arg);
16704         return ((int64_t)ret_conv);
16705 }
16706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16707         LDKC2Tuple_OutPointCVec_MonitorEventZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(arg & ~1);
16708         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(arg_conv);
16709         return ret_conv;
16710 }
16711
16712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16713         LDKC2Tuple_OutPointCVec_MonitorEventZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(orig & ~1);
16714         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
16715         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(orig_conv);
16716         return ((int64_t)ret_conv);
16717 }
16718
16719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b) {
16720         LDKOutPoint a_conv;
16721         a_conv.inner = (void*)(a & (~1));
16722         a_conv.is_owned = (a & 1) || (a == 0);
16723         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16724         a_conv = OutPoint_clone(&a_conv);
16725         LDKCVec_MonitorEventZ b_constr;
16726         b_constr.datalen = (*env)->GetArrayLength(env, b);
16727         if (b_constr.datalen > 0)
16728                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
16729         else
16730                 b_constr.data = NULL;
16731         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
16732         for (size_t o = 0; o < b_constr.datalen; o++) {
16733                 int64_t b_conv_14 = b_vals[o];
16734                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
16735                 CHECK_ACCESS(b_conv_14_ptr);
16736                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
16737                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
16738                 b_constr.data[o] = b_conv_14_conv;
16739         }
16740         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
16741         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
16742         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_new(a_conv, b_constr);
16743         return ((int64_t)ret_conv);
16744 }
16745
16746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorEventZZ_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         LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_ptr);
16751         FREE((void*)_res);
16752         C2Tuple_OutPointCVec_MonitorEventZZ_free(_res_conv);
16753 }
16754
16755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1OutPointCVec_1MonitorEventZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16756         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ _res_constr;
16757         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16758         if (_res_constr.datalen > 0)
16759                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
16760         else
16761                 _res_constr.data = NULL;
16762         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16763         for (size_t m = 0; m < _res_constr.datalen; m++) {
16764                 int64_t _res_conv_38 = _res_vals[m];
16765                 void* _res_conv_38_ptr = (void*)(((uintptr_t)_res_conv_38) & ~1);
16766                 CHECK_ACCESS(_res_conv_38_ptr);
16767                 LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_conv_38_ptr);
16768                 FREE((void*)_res_conv_38);
16769                 _res_constr.data[m] = _res_conv_38_conv;
16770         }
16771         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16772         CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free(_res_constr);
16773 }
16774
16775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16776         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16777         CHECK_ACCESS(o_ptr);
16778         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
16779         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
16780         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16781         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
16782         int64_t ret_ref = (uintptr_t)ret_copy;
16783         return ret_ref;
16784 }
16785
16786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
16787         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16788         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
16789         int64_t ret_ref = (uintptr_t)ret_copy;
16790         return ret_ref;
16791 }
16792
16793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16794         if ((_res & 1) != 0) return;
16795         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16796         CHECK_ACCESS(_res_ptr);
16797         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
16798         FREE((void*)_res);
16799         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
16800 }
16801
16802 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
16803         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16804         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
16805 int64_t ret_ref = (uintptr_t)ret_copy;
16806         return ret_ref;
16807 }
16808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16809         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
16810         int64_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
16811         return ret_conv;
16812 }
16813
16814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16815         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
16816         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
16817         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
16818         int64_t ret_ref = (uintptr_t)ret_copy;
16819         return ret_ref;
16820 }
16821
16822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16823         LDKFixedPenaltyScorer o_conv;
16824         o_conv.inner = (void*)(o & (~1));
16825         o_conv.is_owned = (o & 1) || (o == 0);
16826         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16827         o_conv = FixedPenaltyScorer_clone(&o_conv);
16828         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16829         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
16830         return (int64_t)ret_conv;
16831 }
16832
16833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16834         LDKDecodeError e_conv;
16835         e_conv.inner = (void*)(e & (~1));
16836         e_conv.is_owned = (e & 1) || (e == 0);
16837         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16838         e_conv = DecodeError_clone(&e_conv);
16839         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16840         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
16841         return (int64_t)ret_conv;
16842 }
16843
16844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16845         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
16846         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
16847         return ret_conv;
16848 }
16849
16850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16851         if ((_res & 1) != 0) return;
16852         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16853         CHECK_ACCESS(_res_ptr);
16854         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
16855         FREE((void*)_res);
16856         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
16857 }
16858
16859 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
16860         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16861         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
16862         return (int64_t)ret_conv;
16863 }
16864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16865         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
16866         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
16867         return ret_conv;
16868 }
16869
16870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16871         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
16872         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16873         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
16874         return (int64_t)ret_conv;
16875 }
16876
16877 static inline uintptr_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
16878         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
16879         *ret_conv = C2Tuple_u64u64Z_clone(arg);
16880         return ((int64_t)ret_conv);
16881 }
16882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16883         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)(arg & ~1);
16884         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
16885         return ret_conv;
16886 }
16887
16888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16889         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
16890         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
16891         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
16892         return ((int64_t)ret_conv);
16893 }
16894
16895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
16896         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
16897         *ret_conv = C2Tuple_u64u64Z_new(a, b);
16898         return ((int64_t)ret_conv);
16899 }
16900
16901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16902         if ((_res & 1) != 0) return;
16903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16904         CHECK_ACCESS(_res_ptr);
16905         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
16906         FREE((void*)_res);
16907         C2Tuple_u64u64Z_free(_res_conv);
16908 }
16909
16910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16911         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16912         CHECK_ACCESS(o_ptr);
16913         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
16914         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)(((uintptr_t)o) & ~1));
16915         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16916         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
16917         int64_t ret_ref = (uintptr_t)ret_copy;
16918         return ret_ref;
16919 }
16920
16921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
16922         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16923         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
16924         int64_t ret_ref = (uintptr_t)ret_copy;
16925         return ret_ref;
16926 }
16927
16928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16929         if ((_res & 1) != 0) return;
16930         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16931         CHECK_ACCESS(_res_ptr);
16932         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
16933         FREE((void*)_res);
16934         COption_C2Tuple_u64u64ZZ_free(_res_conv);
16935 }
16936
16937 static inline uintptr_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
16938         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16939         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
16940 int64_t ret_ref = (uintptr_t)ret_copy;
16941         return ret_ref;
16942 }
16943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16944         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)arg;
16945         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
16946         return ret_conv;
16947 }
16948
16949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16950         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)orig;
16951         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
16952         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
16953         int64_t ret_ref = (uintptr_t)ret_copy;
16954         return ret_ref;
16955 }
16956
16957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16958         LDKCVec_NodeIdZ _res_constr;
16959         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16960         if (_res_constr.datalen > 0)
16961                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
16962         else
16963                 _res_constr.data = NULL;
16964         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16965         for (size_t i = 0; i < _res_constr.datalen; i++) {
16966                 int64_t _res_conv_8 = _res_vals[i];
16967                 LDKNodeId _res_conv_8_conv;
16968                 _res_conv_8_conv.inner = (void*)(_res_conv_8 & (~1));
16969                 _res_conv_8_conv.is_owned = (_res_conv_8 & 1) || (_res_conv_8 == 0);
16970                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
16971                 _res_constr.data[i] = _res_conv_8_conv;
16972         }
16973         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16974         CVec_NodeIdZ_free(_res_constr);
16975 }
16976
16977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16978         LDKProbabilisticScorer o_conv;
16979         o_conv.inner = (void*)(o & (~1));
16980         o_conv.is_owned = (o & 1) || (o == 0);
16981         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16982         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
16983         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16984         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
16985         return (int64_t)ret_conv;
16986 }
16987
16988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16989         LDKDecodeError e_conv;
16990         e_conv.inner = (void*)(e & (~1));
16991         e_conv.is_owned = (e & 1) || (e == 0);
16992         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16993         e_conv = DecodeError_clone(&e_conv);
16994         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16995         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
16996         return (int64_t)ret_conv;
16997 }
16998
16999 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17000         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
17001         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
17002         return ret_conv;
17003 }
17004
17005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17006         if ((_res & 1) != 0) return;
17007         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17008         CHECK_ACCESS(_res_ptr);
17009         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
17010         FREE((void*)_res);
17011         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
17012 }
17013
17014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17015         LDKInitFeatures o_conv;
17016         o_conv.inner = (void*)(o & (~1));
17017         o_conv.is_owned = (o & 1) || (o == 0);
17018         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17019         o_conv = InitFeatures_clone(&o_conv);
17020         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17021         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
17022         return (int64_t)ret_conv;
17023 }
17024
17025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17026         LDKDecodeError e_conv;
17027         e_conv.inner = (void*)(e & (~1));
17028         e_conv.is_owned = (e & 1) || (e == 0);
17029         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17030         e_conv = DecodeError_clone(&e_conv);
17031         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17032         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
17033         return (int64_t)ret_conv;
17034 }
17035
17036 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17037         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
17038         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
17039         return ret_conv;
17040 }
17041
17042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17043         if ((_res & 1) != 0) return;
17044         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17045         CHECK_ACCESS(_res_ptr);
17046         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
17047         FREE((void*)_res);
17048         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
17049 }
17050
17051 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17052         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17053         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
17054         return (int64_t)ret_conv;
17055 }
17056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17057         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
17058         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17059         return ret_conv;
17060 }
17061
17062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17063         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
17064         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17065         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
17066         return (int64_t)ret_conv;
17067 }
17068
17069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17070         LDKChannelFeatures o_conv;
17071         o_conv.inner = (void*)(o & (~1));
17072         o_conv.is_owned = (o & 1) || (o == 0);
17073         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17074         o_conv = ChannelFeatures_clone(&o_conv);
17075         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17076         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
17077         return (int64_t)ret_conv;
17078 }
17079
17080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17081         LDKDecodeError e_conv;
17082         e_conv.inner = (void*)(e & (~1));
17083         e_conv.is_owned = (e & 1) || (e == 0);
17084         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17085         e_conv = DecodeError_clone(&e_conv);
17086         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17087         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
17088         return (int64_t)ret_conv;
17089 }
17090
17091 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17092         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
17093         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
17094         return ret_conv;
17095 }
17096
17097 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17098         if ((_res & 1) != 0) return;
17099         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17100         CHECK_ACCESS(_res_ptr);
17101         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
17102         FREE((void*)_res);
17103         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
17104 }
17105
17106 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17107         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17108         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
17109         return (int64_t)ret_conv;
17110 }
17111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17112         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
17113         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17114         return ret_conv;
17115 }
17116
17117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17118         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
17119         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17120         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
17121         return (int64_t)ret_conv;
17122 }
17123
17124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17125         LDKNodeFeatures o_conv;
17126         o_conv.inner = (void*)(o & (~1));
17127         o_conv.is_owned = (o & 1) || (o == 0);
17128         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17129         o_conv = NodeFeatures_clone(&o_conv);
17130         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17131         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
17132         return (int64_t)ret_conv;
17133 }
17134
17135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17136         LDKDecodeError e_conv;
17137         e_conv.inner = (void*)(e & (~1));
17138         e_conv.is_owned = (e & 1) || (e == 0);
17139         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17140         e_conv = DecodeError_clone(&e_conv);
17141         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17142         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
17143         return (int64_t)ret_conv;
17144 }
17145
17146 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17147         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
17148         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
17149         return ret_conv;
17150 }
17151
17152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17153         if ((_res & 1) != 0) return;
17154         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17155         CHECK_ACCESS(_res_ptr);
17156         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
17157         FREE((void*)_res);
17158         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
17159 }
17160
17161 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17162         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17163         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
17164         return (int64_t)ret_conv;
17165 }
17166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17167         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
17168         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17169         return ret_conv;
17170 }
17171
17172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17173         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
17174         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17175         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
17176         return (int64_t)ret_conv;
17177 }
17178
17179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17180         LDKInvoiceFeatures o_conv;
17181         o_conv.inner = (void*)(o & (~1));
17182         o_conv.is_owned = (o & 1) || (o == 0);
17183         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17184         o_conv = InvoiceFeatures_clone(&o_conv);
17185         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17186         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
17187         return (int64_t)ret_conv;
17188 }
17189
17190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17191         LDKDecodeError e_conv;
17192         e_conv.inner = (void*)(e & (~1));
17193         e_conv.is_owned = (e & 1) || (e == 0);
17194         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17195         e_conv = DecodeError_clone(&e_conv);
17196         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17197         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
17198         return (int64_t)ret_conv;
17199 }
17200
17201 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17202         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
17203         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
17204         return ret_conv;
17205 }
17206
17207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17208         if ((_res & 1) != 0) return;
17209         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17210         CHECK_ACCESS(_res_ptr);
17211         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
17212         FREE((void*)_res);
17213         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
17214 }
17215
17216 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17217         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17218         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
17219         return (int64_t)ret_conv;
17220 }
17221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17222         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
17223         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17224         return ret_conv;
17225 }
17226
17227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17228         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
17229         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17230         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
17231         return (int64_t)ret_conv;
17232 }
17233
17234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17235         LDKChannelTypeFeatures o_conv;
17236         o_conv.inner = (void*)(o & (~1));
17237         o_conv.is_owned = (o & 1) || (o == 0);
17238         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17239         o_conv = ChannelTypeFeatures_clone(&o_conv);
17240         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17241         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
17242         return (int64_t)ret_conv;
17243 }
17244
17245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17246         LDKDecodeError e_conv;
17247         e_conv.inner = (void*)(e & (~1));
17248         e_conv.is_owned = (e & 1) || (e == 0);
17249         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17250         e_conv = DecodeError_clone(&e_conv);
17251         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17252         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
17253         return (int64_t)ret_conv;
17254 }
17255
17256 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17257         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
17258         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
17259         return ret_conv;
17260 }
17261
17262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17263         if ((_res & 1) != 0) return;
17264         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17265         CHECK_ACCESS(_res_ptr);
17266         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
17267         FREE((void*)_res);
17268         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
17269 }
17270
17271 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17272         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17273         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
17274         return (int64_t)ret_conv;
17275 }
17276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17277         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
17278         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17279         return ret_conv;
17280 }
17281
17282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17283         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
17284         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
17285         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
17286         return (int64_t)ret_conv;
17287 }
17288
17289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17290         LDKNodeId o_conv;
17291         o_conv.inner = (void*)(o & (~1));
17292         o_conv.is_owned = (o & 1) || (o == 0);
17293         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17294         o_conv = NodeId_clone(&o_conv);
17295         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17296         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
17297         return (int64_t)ret_conv;
17298 }
17299
17300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17301         LDKDecodeError e_conv;
17302         e_conv.inner = (void*)(e & (~1));
17303         e_conv.is_owned = (e & 1) || (e == 0);
17304         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17305         e_conv = DecodeError_clone(&e_conv);
17306         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17307         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
17308         return (int64_t)ret_conv;
17309 }
17310
17311 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17312         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
17313         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
17314         return ret_conv;
17315 }
17316
17317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17318         if ((_res & 1) != 0) return;
17319         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17320         CHECK_ACCESS(_res_ptr);
17321         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
17322         FREE((void*)_res);
17323         CResult_NodeIdDecodeErrorZ_free(_res_conv);
17324 }
17325
17326 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
17327         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17328         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
17329         return (int64_t)ret_conv;
17330 }
17331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17332         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
17333         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
17334         return ret_conv;
17335 }
17336
17337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17338         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
17339         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
17340         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
17341         return (int64_t)ret_conv;
17342 }
17343
17344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17345         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17346         CHECK_ACCESS(o_ptr);
17347         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
17348         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
17349         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17350         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
17351         return (int64_t)ret_conv;
17352 }
17353
17354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17355         LDKDecodeError e_conv;
17356         e_conv.inner = (void*)(e & (~1));
17357         e_conv.is_owned = (e & 1) || (e == 0);
17358         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17359         e_conv = DecodeError_clone(&e_conv);
17360         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17361         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
17362         return (int64_t)ret_conv;
17363 }
17364
17365 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17366         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
17367         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
17368         return ret_conv;
17369 }
17370
17371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17372         if ((_res & 1) != 0) return;
17373         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17374         CHECK_ACCESS(_res_ptr);
17375         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
17376         FREE((void*)_res);
17377         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
17378 }
17379
17380 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
17381         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17382         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
17383         return (int64_t)ret_conv;
17384 }
17385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17386         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
17387         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
17388         return ret_conv;
17389 }
17390
17391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17392         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
17393         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
17394         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
17395         return (int64_t)ret_conv;
17396 }
17397
17398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17399         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17400         CHECK_ACCESS(o_ptr);
17401         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
17402         if (o_conv.free == LDKAccess_JCalls_free) {
17403                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17404                 LDKAccess_JCalls_cloned(&o_conv);
17405         }
17406         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17407         *ret_copy = COption_AccessZ_some(o_conv);
17408         int64_t ret_ref = (uintptr_t)ret_copy;
17409         return ret_ref;
17410 }
17411
17412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
17413         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
17414         *ret_copy = COption_AccessZ_none();
17415         int64_t ret_ref = (uintptr_t)ret_copy;
17416         return ret_ref;
17417 }
17418
17419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17420         if ((_res & 1) != 0) return;
17421         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17422         CHECK_ACCESS(_res_ptr);
17423         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
17424         FREE((void*)_res);
17425         COption_AccessZ_free(_res_conv);
17426 }
17427
17428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
17429         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17430         *ret_conv = CResult_boolLightningErrorZ_ok(o);
17431         return (int64_t)ret_conv;
17432 }
17433
17434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17435         LDKLightningError e_conv;
17436         e_conv.inner = (void*)(e & (~1));
17437         e_conv.is_owned = (e & 1) || (e == 0);
17438         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17439         e_conv = LightningError_clone(&e_conv);
17440         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17441         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
17442         return (int64_t)ret_conv;
17443 }
17444
17445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17446         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
17447         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
17448         return ret_conv;
17449 }
17450
17451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17452         if ((_res & 1) != 0) return;
17453         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17454         CHECK_ACCESS(_res_ptr);
17455         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
17456         FREE((void*)_res);
17457         CResult_boolLightningErrorZ_free(_res_conv);
17458 }
17459
17460 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
17461         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17462         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
17463         return (int64_t)ret_conv;
17464 }
17465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17466         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
17467         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
17468         return ret_conv;
17469 }
17470
17471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17472         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
17473         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
17474         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
17475         return (int64_t)ret_conv;
17476 }
17477
17478 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
17479         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17480         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
17481         return ((int64_t)ret_conv);
17482 }
17483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17484         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
17485         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
17486         return ret_conv;
17487 }
17488
17489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17490         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
17491         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17492         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
17493         return ((int64_t)ret_conv);
17494 }
17495
17496 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) {
17497         LDKChannelAnnouncement a_conv;
17498         a_conv.inner = (void*)(a & (~1));
17499         a_conv.is_owned = (a & 1) || (a == 0);
17500         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17501         a_conv = ChannelAnnouncement_clone(&a_conv);
17502         LDKChannelUpdate b_conv;
17503         b_conv.inner = (void*)(b & (~1));
17504         b_conv.is_owned = (b & 1) || (b == 0);
17505         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17506         b_conv = ChannelUpdate_clone(&b_conv);
17507         LDKChannelUpdate c_conv;
17508         c_conv.inner = (void*)(c & (~1));
17509         c_conv.is_owned = (c & 1) || (c == 0);
17510         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
17511         c_conv = ChannelUpdate_clone(&c_conv);
17512         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
17513         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
17514         return ((int64_t)ret_conv);
17515 }
17516
17517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17518         if ((_res & 1) != 0) return;
17519         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17520         CHECK_ACCESS(_res_ptr);
17521         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
17522         FREE((void*)_res);
17523         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
17524 }
17525
17526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17527         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
17528         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17529         if (_res_constr.datalen > 0)
17530                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
17531         else
17532                 _res_constr.data = NULL;
17533         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17534         for (size_t h = 0; h < _res_constr.datalen; h++) {
17535                 int64_t _res_conv_59 = _res_vals[h];
17536                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
17537                 CHECK_ACCESS(_res_conv_59_ptr);
17538                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
17539                 FREE((void*)_res_conv_59);
17540                 _res_constr.data[h] = _res_conv_59_conv;
17541         }
17542         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17543         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
17544 }
17545
17546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17547         LDKCVec_NodeAnnouncementZ _res_constr;
17548         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17549         if (_res_constr.datalen > 0)
17550                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
17551         else
17552                 _res_constr.data = NULL;
17553         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17554         for (size_t s = 0; s < _res_constr.datalen; s++) {
17555                 int64_t _res_conv_18 = _res_vals[s];
17556                 LDKNodeAnnouncement _res_conv_18_conv;
17557                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
17558                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
17559                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
17560                 _res_constr.data[s] = _res_conv_18_conv;
17561         }
17562         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17563         CVec_NodeAnnouncementZ_free(_res_constr);
17564 }
17565
17566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
17567         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17568         *ret_conv = CResult_NoneLightningErrorZ_ok();
17569         return (int64_t)ret_conv;
17570 }
17571
17572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17573         LDKLightningError e_conv;
17574         e_conv.inner = (void*)(e & (~1));
17575         e_conv.is_owned = (e & 1) || (e == 0);
17576         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17577         e_conv = LightningError_clone(&e_conv);
17578         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17579         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
17580         return (int64_t)ret_conv;
17581 }
17582
17583 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17584         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
17585         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
17586         return ret_conv;
17587 }
17588
17589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17590         if ((_res & 1) != 0) return;
17591         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17592         CHECK_ACCESS(_res_ptr);
17593         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
17594         FREE((void*)_res);
17595         CResult_NoneLightningErrorZ_free(_res_conv);
17596 }
17597
17598 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
17599         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17600         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
17601         return (int64_t)ret_conv;
17602 }
17603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17604         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
17605         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
17606         return ret_conv;
17607 }
17608
17609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17610         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
17611         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
17612         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
17613         return (int64_t)ret_conv;
17614 }
17615
17616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17617         LDKChannelUpdateInfo o_conv;
17618         o_conv.inner = (void*)(o & (~1));
17619         o_conv.is_owned = (o & 1) || (o == 0);
17620         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17621         o_conv = ChannelUpdateInfo_clone(&o_conv);
17622         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17623         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
17624         return (int64_t)ret_conv;
17625 }
17626
17627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17628         LDKDecodeError e_conv;
17629         e_conv.inner = (void*)(e & (~1));
17630         e_conv.is_owned = (e & 1) || (e == 0);
17631         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17632         e_conv = DecodeError_clone(&e_conv);
17633         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17634         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
17635         return (int64_t)ret_conv;
17636 }
17637
17638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17639         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
17640         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
17641         return ret_conv;
17642 }
17643
17644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17645         if ((_res & 1) != 0) return;
17646         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17647         CHECK_ACCESS(_res_ptr);
17648         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
17649         FREE((void*)_res);
17650         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
17651 }
17652
17653 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
17654         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17655         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
17656         return (int64_t)ret_conv;
17657 }
17658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17659         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
17660         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
17661         return ret_conv;
17662 }
17663
17664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17665         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
17666         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17667         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
17668         return (int64_t)ret_conv;
17669 }
17670
17671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17672         LDKChannelInfo o_conv;
17673         o_conv.inner = (void*)(o & (~1));
17674         o_conv.is_owned = (o & 1) || (o == 0);
17675         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17676         o_conv = ChannelInfo_clone(&o_conv);
17677         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17678         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
17679         return (int64_t)ret_conv;
17680 }
17681
17682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17683         LDKDecodeError e_conv;
17684         e_conv.inner = (void*)(e & (~1));
17685         e_conv.is_owned = (e & 1) || (e == 0);
17686         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17687         e_conv = DecodeError_clone(&e_conv);
17688         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17689         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
17690         return (int64_t)ret_conv;
17691 }
17692
17693 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17694         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
17695         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
17696         return ret_conv;
17697 }
17698
17699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17700         if ((_res & 1) != 0) return;
17701         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17702         CHECK_ACCESS(_res_ptr);
17703         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
17704         FREE((void*)_res);
17705         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
17706 }
17707
17708 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
17709         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17710         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
17711         return (int64_t)ret_conv;
17712 }
17713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17714         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
17715         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
17716         return ret_conv;
17717 }
17718
17719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17720         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
17721         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17722         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
17723         return (int64_t)ret_conv;
17724 }
17725
17726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17727         LDKRoutingFees o_conv;
17728         o_conv.inner = (void*)(o & (~1));
17729         o_conv.is_owned = (o & 1) || (o == 0);
17730         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17731         o_conv = RoutingFees_clone(&o_conv);
17732         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17733         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
17734         return (int64_t)ret_conv;
17735 }
17736
17737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17738         LDKDecodeError e_conv;
17739         e_conv.inner = (void*)(e & (~1));
17740         e_conv.is_owned = (e & 1) || (e == 0);
17741         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17742         e_conv = DecodeError_clone(&e_conv);
17743         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17744         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
17745         return (int64_t)ret_conv;
17746 }
17747
17748 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17749         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
17750         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
17751         return ret_conv;
17752 }
17753
17754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17755         if ((_res & 1) != 0) return;
17756         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17757         CHECK_ACCESS(_res_ptr);
17758         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
17759         FREE((void*)_res);
17760         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
17761 }
17762
17763 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
17764         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17765         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
17766         return (int64_t)ret_conv;
17767 }
17768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17769         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
17770         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
17771         return ret_conv;
17772 }
17773
17774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17775         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
17776         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17777         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
17778         return (int64_t)ret_conv;
17779 }
17780
17781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17782         LDKCVec_NetAddressZ _res_constr;
17783         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17784         if (_res_constr.datalen > 0)
17785                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17786         else
17787                 _res_constr.data = NULL;
17788         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17789         for (size_t m = 0; m < _res_constr.datalen; m++) {
17790                 int64_t _res_conv_12 = _res_vals[m];
17791                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
17792                 CHECK_ACCESS(_res_conv_12_ptr);
17793                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
17794                 FREE((void*)_res_conv_12);
17795                 _res_constr.data[m] = _res_conv_12_conv;
17796         }
17797         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17798         CVec_NetAddressZ_free(_res_constr);
17799 }
17800
17801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17802         LDKNodeAnnouncementInfo o_conv;
17803         o_conv.inner = (void*)(o & (~1));
17804         o_conv.is_owned = (o & 1) || (o == 0);
17805         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17806         o_conv = NodeAnnouncementInfo_clone(&o_conv);
17807         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17808         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
17809         return (int64_t)ret_conv;
17810 }
17811
17812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17813         LDKDecodeError e_conv;
17814         e_conv.inner = (void*)(e & (~1));
17815         e_conv.is_owned = (e & 1) || (e == 0);
17816         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17817         e_conv = DecodeError_clone(&e_conv);
17818         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17819         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
17820         return (int64_t)ret_conv;
17821 }
17822
17823 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17824         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
17825         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
17826         return ret_conv;
17827 }
17828
17829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17830         if ((_res & 1) != 0) return;
17831         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17832         CHECK_ACCESS(_res_ptr);
17833         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
17834         FREE((void*)_res);
17835         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
17836 }
17837
17838 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
17839         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17840         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
17841         return (int64_t)ret_conv;
17842 }
17843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17844         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
17845         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
17846         return ret_conv;
17847 }
17848
17849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17850         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
17851         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17852         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
17853         return (int64_t)ret_conv;
17854 }
17855
17856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17857         LDKNodeAlias o_conv;
17858         o_conv.inner = (void*)(o & (~1));
17859         o_conv.is_owned = (o & 1) || (o == 0);
17860         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17861         o_conv = NodeAlias_clone(&o_conv);
17862         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17863         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
17864         return (int64_t)ret_conv;
17865 }
17866
17867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17868         LDKDecodeError e_conv;
17869         e_conv.inner = (void*)(e & (~1));
17870         e_conv.is_owned = (e & 1) || (e == 0);
17871         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17872         e_conv = DecodeError_clone(&e_conv);
17873         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17874         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
17875         return (int64_t)ret_conv;
17876 }
17877
17878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17879         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(o & ~1);
17880         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
17881         return ret_conv;
17882 }
17883
17884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17885         if ((_res & 1) != 0) return;
17886         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17887         CHECK_ACCESS(_res_ptr);
17888         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
17889         FREE((void*)_res);
17890         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
17891 }
17892
17893 static inline uintptr_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
17894         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17895         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
17896         return (int64_t)ret_conv;
17897 }
17898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17899         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(arg & ~1);
17900         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
17901         return ret_conv;
17902 }
17903
17904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17905         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)(orig & ~1);
17906         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
17907         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
17908         return (int64_t)ret_conv;
17909 }
17910
17911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17912         LDKCVec_u64Z _res_constr;
17913         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17914         if (_res_constr.datalen > 0)
17915                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17916         else
17917                 _res_constr.data = NULL;
17918         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17919         for (size_t g = 0; g < _res_constr.datalen; g++) {
17920                 int64_t _res_conv_6 = _res_vals[g];
17921                 _res_constr.data[g] = _res_conv_6;
17922         }
17923         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17924         CVec_u64Z_free(_res_constr);
17925 }
17926
17927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17928         LDKNodeInfo o_conv;
17929         o_conv.inner = (void*)(o & (~1));
17930         o_conv.is_owned = (o & 1) || (o == 0);
17931         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17932         o_conv = NodeInfo_clone(&o_conv);
17933         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17934         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
17935         return (int64_t)ret_conv;
17936 }
17937
17938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17939         LDKDecodeError e_conv;
17940         e_conv.inner = (void*)(e & (~1));
17941         e_conv.is_owned = (e & 1) || (e == 0);
17942         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17943         e_conv = DecodeError_clone(&e_conv);
17944         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17945         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
17946         return (int64_t)ret_conv;
17947 }
17948
17949 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17950         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
17951         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
17952         return ret_conv;
17953 }
17954
17955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17956         if ((_res & 1) != 0) return;
17957         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17958         CHECK_ACCESS(_res_ptr);
17959         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17960         FREE((void*)_res);
17961         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17962 }
17963
17964 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17965         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17966         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17967         return (int64_t)ret_conv;
17968 }
17969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17970         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
17971         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17972         return ret_conv;
17973 }
17974
17975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17976         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
17977         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17978         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17979         return (int64_t)ret_conv;
17980 }
17981
17982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17983         LDKNetworkGraph o_conv;
17984         o_conv.inner = (void*)(o & (~1));
17985         o_conv.is_owned = (o & 1) || (o == 0);
17986         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17987         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
17988         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17989         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17990         return (int64_t)ret_conv;
17991 }
17992
17993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17994         LDKDecodeError e_conv;
17995         e_conv.inner = (void*)(e & (~1));
17996         e_conv.is_owned = (e & 1) || (e == 0);
17997         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17998         e_conv = DecodeError_clone(&e_conv);
17999         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18000         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
18001         return (int64_t)ret_conv;
18002 }
18003
18004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18005         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
18006         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
18007         return ret_conv;
18008 }
18009
18010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18011         if ((_res & 1) != 0) return;
18012         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18013         CHECK_ACCESS(_res_ptr);
18014         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
18015         FREE((void*)_res);
18016         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
18017 }
18018
18019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
18020         LDKCVec_NetAddressZ o_constr;
18021         o_constr.datalen = (*env)->GetArrayLength(env, o);
18022         if (o_constr.datalen > 0)
18023                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18024         else
18025                 o_constr.data = NULL;
18026         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
18027         for (size_t m = 0; m < o_constr.datalen; m++) {
18028                 int64_t o_conv_12 = o_vals[m];
18029                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
18030                 CHECK_ACCESS(o_conv_12_ptr);
18031                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
18032                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
18033                 o_constr.data[m] = o_conv_12_conv;
18034         }
18035         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
18036         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18037         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
18038         int64_t ret_ref = (uintptr_t)ret_copy;
18039         return ret_ref;
18040 }
18041
18042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
18043         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18044         *ret_copy = COption_CVec_NetAddressZZ_none();
18045         int64_t ret_ref = (uintptr_t)ret_copy;
18046         return ret_ref;
18047 }
18048
18049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18050         if ((_res & 1) != 0) return;
18051         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18052         CHECK_ACCESS(_res_ptr);
18053         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
18054         FREE((void*)_res);
18055         COption_CVec_NetAddressZZ_free(_res_conv);
18056 }
18057
18058 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
18059         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18060         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
18061 int64_t ret_ref = (uintptr_t)ret_copy;
18062         return ret_ref;
18063 }
18064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18065         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
18066         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
18067         return ret_conv;
18068 }
18069
18070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18071         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
18072         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18073         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
18074         int64_t ret_ref = (uintptr_t)ret_copy;
18075         return ret_ref;
18076 }
18077
18078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18079         LDKDelayedPaymentOutputDescriptor o_conv;
18080         o_conv.inner = (void*)(o & (~1));
18081         o_conv.is_owned = (o & 1) || (o == 0);
18082         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18083         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
18084         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18085         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18086         return (int64_t)ret_conv;
18087 }
18088
18089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18090         LDKDecodeError e_conv;
18091         e_conv.inner = (void*)(e & (~1));
18092         e_conv.is_owned = (e & 1) || (e == 0);
18093         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18094         e_conv = DecodeError_clone(&e_conv);
18095         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18096         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18097         return (int64_t)ret_conv;
18098 }
18099
18100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18101         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
18102         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18103         return ret_conv;
18104 }
18105
18106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18107         if ((_res & 1) != 0) return;
18108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18109         CHECK_ACCESS(_res_ptr);
18110         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18111         FREE((void*)_res);
18112         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18113 }
18114
18115 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18116         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18117         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18118         return (int64_t)ret_conv;
18119 }
18120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18121         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
18122         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18123         return ret_conv;
18124 }
18125
18126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18127         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
18128         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18129         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18130         return (int64_t)ret_conv;
18131 }
18132
18133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18134         LDKStaticPaymentOutputDescriptor o_conv;
18135         o_conv.inner = (void*)(o & (~1));
18136         o_conv.is_owned = (o & 1) || (o == 0);
18137         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18138         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
18139         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18140         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18141         return (int64_t)ret_conv;
18142 }
18143
18144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18145         LDKDecodeError e_conv;
18146         e_conv.inner = (void*)(e & (~1));
18147         e_conv.is_owned = (e & 1) || (e == 0);
18148         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18149         e_conv = DecodeError_clone(&e_conv);
18150         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18151         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18152         return (int64_t)ret_conv;
18153 }
18154
18155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18156         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
18157         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18158         return ret_conv;
18159 }
18160
18161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18162         if ((_res & 1) != 0) return;
18163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18164         CHECK_ACCESS(_res_ptr);
18165         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18166         FREE((void*)_res);
18167         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18168 }
18169
18170 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18171         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18172         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18173         return (int64_t)ret_conv;
18174 }
18175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18176         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
18177         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18178         return ret_conv;
18179 }
18180
18181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18182         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
18183         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18184         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18185         return (int64_t)ret_conv;
18186 }
18187
18188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18189         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18190         CHECK_ACCESS(o_ptr);
18191         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
18192         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
18193         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18194         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
18195         return (int64_t)ret_conv;
18196 }
18197
18198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18199         LDKDecodeError e_conv;
18200         e_conv.inner = (void*)(e & (~1));
18201         e_conv.is_owned = (e & 1) || (e == 0);
18202         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18203         e_conv = DecodeError_clone(&e_conv);
18204         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18205         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
18206         return (int64_t)ret_conv;
18207 }
18208
18209 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18210         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
18211         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18212         return ret_conv;
18213 }
18214
18215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18216         if ((_res & 1) != 0) return;
18217         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18218         CHECK_ACCESS(_res_ptr);
18219         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
18220         FREE((void*)_res);
18221         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
18222 }
18223
18224 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18225         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18226         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
18227         return (int64_t)ret_conv;
18228 }
18229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18230         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
18231         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18232         return ret_conv;
18233 }
18234
18235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18236         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
18237         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18238         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
18239         return (int64_t)ret_conv;
18240 }
18241
18242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18243         LDKCVec_PaymentPreimageZ _res_constr;
18244         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18245         if (_res_constr.datalen > 0)
18246                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
18247         else
18248                 _res_constr.data = NULL;
18249         for (size_t i = 0; i < _res_constr.datalen; i++) {
18250                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18251                 LDKThirtyTwoBytes _res_conv_8_ref;
18252                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
18253                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
18254                 _res_constr.data[i] = _res_conv_8_ref;
18255         }
18256         CVec_PaymentPreimageZ_free(_res_constr);
18257 }
18258
18259 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
18260         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18261         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
18262         return ((int64_t)ret_conv);
18263 }
18264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18265         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
18266         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
18267         return ret_conv;
18268 }
18269
18270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18271         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
18272         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18273         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
18274         return ((int64_t)ret_conv);
18275 }
18276
18277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
18278         LDKSignature a_ref;
18279         CHECK((*env)->GetArrayLength(env, a) == 64);
18280         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18281         LDKCVec_SignatureZ b_constr;
18282         b_constr.datalen = (*env)->GetArrayLength(env, b);
18283         if (b_constr.datalen > 0)
18284                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
18285         else
18286                 b_constr.data = NULL;
18287         for (size_t i = 0; i < b_constr.datalen; i++) {
18288                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
18289                 LDKSignature b_conv_8_ref;
18290                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
18291                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
18292                 b_constr.data[i] = b_conv_8_ref;
18293         }
18294         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
18295         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
18296         return ((int64_t)ret_conv);
18297 }
18298
18299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18300         if ((_res & 1) != 0) return;
18301         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18302         CHECK_ACCESS(_res_ptr);
18303         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
18304         FREE((void*)_res);
18305         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
18306 }
18307
18308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18309         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18310         CHECK_ACCESS(o_ptr);
18311         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
18312         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
18313         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18314         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
18315         return (int64_t)ret_conv;
18316 }
18317
18318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
18319         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18320         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
18321         return (int64_t)ret_conv;
18322 }
18323
18324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18325         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
18326         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
18327         return ret_conv;
18328 }
18329
18330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18331         if ((_res & 1) != 0) return;
18332         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18333         CHECK_ACCESS(_res_ptr);
18334         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
18335         FREE((void*)_res);
18336         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
18337 }
18338
18339 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
18340         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18341         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
18342         return (int64_t)ret_conv;
18343 }
18344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18345         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
18346         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
18347         return ret_conv;
18348 }
18349
18350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18351         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
18352         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
18353         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
18354         return (int64_t)ret_conv;
18355 }
18356
18357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18358         LDKSignature o_ref;
18359         CHECK((*env)->GetArrayLength(env, o) == 64);
18360         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
18361         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18362         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
18363         return (int64_t)ret_conv;
18364 }
18365
18366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
18367         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18368         *ret_conv = CResult_SignatureNoneZ_err();
18369         return (int64_t)ret_conv;
18370 }
18371
18372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18373         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
18374         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
18375         return ret_conv;
18376 }
18377
18378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18379         if ((_res & 1) != 0) return;
18380         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18381         CHECK_ACCESS(_res_ptr);
18382         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
18383         FREE((void*)_res);
18384         CResult_SignatureNoneZ_free(_res_conv);
18385 }
18386
18387 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
18388         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18389         *ret_conv = CResult_SignatureNoneZ_clone(arg);
18390         return (int64_t)ret_conv;
18391 }
18392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18393         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
18394         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
18395         return ret_conv;
18396 }
18397
18398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18399         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
18400         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
18401         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
18402         return (int64_t)ret_conv;
18403 }
18404
18405 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
18406         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18407         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
18408         return ((int64_t)ret_conv);
18409 }
18410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18411         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
18412         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
18413         return ret_conv;
18414 }
18415
18416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18417         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
18418         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18419         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
18420         return ((int64_t)ret_conv);
18421 }
18422
18423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18424         LDKSignature a_ref;
18425         CHECK((*env)->GetArrayLength(env, a) == 64);
18426         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
18427         LDKSignature b_ref;
18428         CHECK((*env)->GetArrayLength(env, b) == 64);
18429         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
18430         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
18431         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
18432         return ((int64_t)ret_conv);
18433 }
18434
18435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18436         if ((_res & 1) != 0) return;
18437         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18438         CHECK_ACCESS(_res_ptr);
18439         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
18440         FREE((void*)_res);
18441         C2Tuple_SignatureSignatureZ_free(_res_conv);
18442 }
18443
18444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18445         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18446         CHECK_ACCESS(o_ptr);
18447         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
18448         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
18449         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18450         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
18451         return (int64_t)ret_conv;
18452 }
18453
18454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
18455         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18456         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
18457         return (int64_t)ret_conv;
18458 }
18459
18460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18461         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
18462         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
18463         return ret_conv;
18464 }
18465
18466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18467         if ((_res & 1) != 0) return;
18468         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18469         CHECK_ACCESS(_res_ptr);
18470         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
18471         FREE((void*)_res);
18472         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
18473 }
18474
18475 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
18476         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18477         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
18478         return (int64_t)ret_conv;
18479 }
18480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18481         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
18482         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
18483         return ret_conv;
18484 }
18485
18486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18487         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
18488         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
18489         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
18490         return (int64_t)ret_conv;
18491 }
18492
18493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18494         LDKSecretKey o_ref;
18495         CHECK((*env)->GetArrayLength(env, o) == 32);
18496         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
18497         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18498         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
18499         return (int64_t)ret_conv;
18500 }
18501
18502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
18503         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18504         *ret_conv = CResult_SecretKeyNoneZ_err();
18505         return (int64_t)ret_conv;
18506 }
18507
18508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18509         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
18510         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
18511         return ret_conv;
18512 }
18513
18514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18515         if ((_res & 1) != 0) return;
18516         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18517         CHECK_ACCESS(_res_ptr);
18518         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
18519         FREE((void*)_res);
18520         CResult_SecretKeyNoneZ_free(_res_conv);
18521 }
18522
18523 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
18524         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18525         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
18526         return (int64_t)ret_conv;
18527 }
18528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18529         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
18530         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
18531         return ret_conv;
18532 }
18533
18534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18535         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
18536         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
18537         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
18538         return (int64_t)ret_conv;
18539 }
18540
18541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18542         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18543         CHECK_ACCESS(o_ptr);
18544         LDKSign o_conv = *(LDKSign*)(o_ptr);
18545         if (o_conv.free == LDKSign_JCalls_free) {
18546                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18547                 LDKSign_JCalls_cloned(&o_conv);
18548         }
18549         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18550         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
18551         return (int64_t)ret_conv;
18552 }
18553
18554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18555         LDKDecodeError e_conv;
18556         e_conv.inner = (void*)(e & (~1));
18557         e_conv.is_owned = (e & 1) || (e == 0);
18558         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18559         e_conv = DecodeError_clone(&e_conv);
18560         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18561         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
18562         return (int64_t)ret_conv;
18563 }
18564
18565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18566         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
18567         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
18568         return ret_conv;
18569 }
18570
18571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18572         if ((_res & 1) != 0) return;
18573         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18574         CHECK_ACCESS(_res_ptr);
18575         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
18576         FREE((void*)_res);
18577         CResult_SignDecodeErrorZ_free(_res_conv);
18578 }
18579
18580 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
18581         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18582         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
18583         return (int64_t)ret_conv;
18584 }
18585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18586         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
18587         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
18588         return ret_conv;
18589 }
18590
18591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18592         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
18593         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
18594         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
18595         return (int64_t)ret_conv;
18596 }
18597
18598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18599         LDKCVec_u5Z _res_constr;
18600         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18601         if (_res_constr.datalen > 0)
18602                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
18603         else
18604                 _res_constr.data = NULL;
18605         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
18606         for (size_t h = 0; h < _res_constr.datalen; h++) {
18607                 int8_t _res_conv_7 = _res_vals[h];
18608                 
18609                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
18610         }
18611         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
18612         CVec_u5Z_free(_res_constr);
18613 }
18614
18615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18616         LDKRecoverableSignature o_ref;
18617         CHECK((*env)->GetArrayLength(env, o) == 68);
18618         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
18619         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18620         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
18621         return (int64_t)ret_conv;
18622 }
18623
18624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
18625         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18626         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
18627         return (int64_t)ret_conv;
18628 }
18629
18630 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18631         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
18632         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
18633         return ret_conv;
18634 }
18635
18636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18637         if ((_res & 1) != 0) return;
18638         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18639         CHECK_ACCESS(_res_ptr);
18640         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
18641         FREE((void*)_res);
18642         CResult_RecoverableSignatureNoneZ_free(_res_conv);
18643 }
18644
18645 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
18646         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18647         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
18648         return (int64_t)ret_conv;
18649 }
18650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18651         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
18652         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
18653         return ret_conv;
18654 }
18655
18656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18657         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
18658         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
18659         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
18660         return (int64_t)ret_conv;
18661 }
18662
18663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
18664         LDKCVec_u8Z _res_ref;
18665         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
18666         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
18667         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
18668         CVec_u8Z_free(_res_ref);
18669 }
18670
18671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
18672         LDKCVec_CVec_u8ZZ _res_constr;
18673         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18674         if (_res_constr.datalen > 0)
18675                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
18676         else
18677                 _res_constr.data = NULL;
18678         for (size_t i = 0; i < _res_constr.datalen; i++) {
18679                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
18680                 LDKCVec_u8Z _res_conv_8_ref;
18681                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
18682                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
18683                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
18684                 _res_constr.data[i] = _res_conv_8_ref;
18685         }
18686         CVec_CVec_u8ZZ_free(_res_constr);
18687 }
18688
18689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
18690         LDKCVec_CVec_u8ZZ o_constr;
18691         o_constr.datalen = (*env)->GetArrayLength(env, o);
18692         if (o_constr.datalen > 0)
18693                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
18694         else
18695                 o_constr.data = NULL;
18696         for (size_t i = 0; i < o_constr.datalen; i++) {
18697                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
18698                 LDKCVec_u8Z o_conv_8_ref;
18699                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
18700                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
18701                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
18702                 o_constr.data[i] = o_conv_8_ref;
18703         }
18704         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18705         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
18706         return (int64_t)ret_conv;
18707 }
18708
18709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
18710         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18711         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
18712         return (int64_t)ret_conv;
18713 }
18714
18715 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18716         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
18717         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
18718         return ret_conv;
18719 }
18720
18721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18722         if ((_res & 1) != 0) return;
18723         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18724         CHECK_ACCESS(_res_ptr);
18725         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
18726         FREE((void*)_res);
18727         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
18728 }
18729
18730 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
18731         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18732         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
18733         return (int64_t)ret_conv;
18734 }
18735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18736         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
18737         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
18738         return ret_conv;
18739 }
18740
18741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18742         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
18743         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
18744         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
18745         return (int64_t)ret_conv;
18746 }
18747
18748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18749         LDKInMemorySigner o_conv;
18750         o_conv.inner = (void*)(o & (~1));
18751         o_conv.is_owned = (o & 1) || (o == 0);
18752         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18753         o_conv = InMemorySigner_clone(&o_conv);
18754         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18755         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
18756         return (int64_t)ret_conv;
18757 }
18758
18759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18760         LDKDecodeError e_conv;
18761         e_conv.inner = (void*)(e & (~1));
18762         e_conv.is_owned = (e & 1) || (e == 0);
18763         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18764         e_conv = DecodeError_clone(&e_conv);
18765         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18766         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
18767         return (int64_t)ret_conv;
18768 }
18769
18770 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18771         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
18772         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
18773         return ret_conv;
18774 }
18775
18776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18777         if ((_res & 1) != 0) return;
18778         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18779         CHECK_ACCESS(_res_ptr);
18780         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
18781         FREE((void*)_res);
18782         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
18783 }
18784
18785 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
18786         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18787         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
18788         return (int64_t)ret_conv;
18789 }
18790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18791         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
18792         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
18793         return ret_conv;
18794 }
18795
18796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18797         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
18798         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
18799         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
18800         return (int64_t)ret_conv;
18801 }
18802
18803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18804         LDKCVec_TxOutZ _res_constr;
18805         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18806         if (_res_constr.datalen > 0)
18807                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
18808         else
18809                 _res_constr.data = NULL;
18810         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18811         for (size_t h = 0; h < _res_constr.datalen; h++) {
18812                 int64_t _res_conv_7 = _res_vals[h];
18813                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
18814                 CHECK_ACCESS(_res_conv_7_ptr);
18815                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
18816                 FREE((void*)_res_conv_7);
18817                 _res_constr.data[h] = _res_conv_7_conv;
18818         }
18819         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18820         CVec_TxOutZ_free(_res_constr);
18821 }
18822
18823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18824         LDKTransaction o_ref;
18825         o_ref.datalen = (*env)->GetArrayLength(env, o);
18826         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
18827         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
18828         o_ref.data_is_owned = true;
18829         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18830         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
18831         return (int64_t)ret_conv;
18832 }
18833
18834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
18835         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18836         *ret_conv = CResult_TransactionNoneZ_err();
18837         return (int64_t)ret_conv;
18838 }
18839
18840 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18841         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
18842         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
18843         return ret_conv;
18844 }
18845
18846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18847         if ((_res & 1) != 0) return;
18848         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18849         CHECK_ACCESS(_res_ptr);
18850         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
18851         FREE((void*)_res);
18852         CResult_TransactionNoneZ_free(_res_conv);
18853 }
18854
18855 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
18856         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18857         *ret_conv = CResult_TransactionNoneZ_clone(arg);
18858         return (int64_t)ret_conv;
18859 }
18860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18861         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
18862         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
18863         return ret_conv;
18864 }
18865
18866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18867         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
18868         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
18869         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
18870         return (int64_t)ret_conv;
18871 }
18872
18873 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
18874         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18875         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
18876         return ((int64_t)ret_conv);
18877 }
18878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18879         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
18880         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
18881         return ret_conv;
18882 }
18883
18884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18885         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
18886         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18887         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
18888         return ((int64_t)ret_conv);
18889 }
18890
18891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
18892         LDKThirtyTwoBytes a_ref;
18893         CHECK((*env)->GetArrayLength(env, a) == 32);
18894         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18895         LDKChannelMonitor b_conv;
18896         b_conv.inner = (void*)(b & (~1));
18897         b_conv.is_owned = (b & 1) || (b == 0);
18898         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18899         b_conv = ChannelMonitor_clone(&b_conv);
18900         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
18901         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
18902         return ((int64_t)ret_conv);
18903 }
18904
18905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18906         if ((_res & 1) != 0) return;
18907         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18908         CHECK_ACCESS(_res_ptr);
18909         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
18910         FREE((void*)_res);
18911         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
18912 }
18913
18914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18915         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
18916         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18917         if (_res_constr.datalen > 0)
18918                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
18919         else
18920                 _res_constr.data = NULL;
18921         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18922         for (size_t j = 0; j < _res_constr.datalen; j++) {
18923                 int64_t _res_conv_35 = _res_vals[j];
18924                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
18925                 CHECK_ACCESS(_res_conv_35_ptr);
18926                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
18927                 FREE((void*)_res_conv_35);
18928                 _res_constr.data[j] = _res_conv_35_conv;
18929         }
18930         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18931         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
18932 }
18933
18934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
18935         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
18936         o_constr.datalen = (*env)->GetArrayLength(env, o);
18937         if (o_constr.datalen > 0)
18938                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
18939         else
18940                 o_constr.data = NULL;
18941         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
18942         for (size_t j = 0; j < o_constr.datalen; j++) {
18943                 int64_t o_conv_35 = o_vals[j];
18944                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
18945                 CHECK_ACCESS(o_conv_35_ptr);
18946                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
18947                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
18948                 o_constr.data[j] = o_conv_35_conv;
18949         }
18950         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
18951         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18952         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
18953         return (int64_t)ret_conv;
18954 }
18955
18956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18957         LDKIOError e_conv = LDKIOError_from_java(env, e);
18958         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18959         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
18960         return (int64_t)ret_conv;
18961 }
18962
18963 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18964         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
18965         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
18966         return ret_conv;
18967 }
18968
18969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18970         if ((_res & 1) != 0) return;
18971         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18972         CHECK_ACCESS(_res_ptr);
18973         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
18974         FREE((void*)_res);
18975         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
18976 }
18977
18978 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
18979         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18980         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
18981         return (int64_t)ret_conv;
18982 }
18983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18984         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
18985         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
18986         return ret_conv;
18987 }
18988
18989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18990         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
18991         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
18992         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
18993         return (int64_t)ret_conv;
18994 }
18995
18996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
18997         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
18998         *ret_copy = COption_u16Z_some(o);
18999         int64_t ret_ref = (uintptr_t)ret_copy;
19000         return ret_ref;
19001 }
19002
19003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
19004         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19005         *ret_copy = COption_u16Z_none();
19006         int64_t ret_ref = (uintptr_t)ret_copy;
19007         return ret_ref;
19008 }
19009
19010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
19011         if ((_res & 1) != 0) return;
19012         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19013         CHECK_ACCESS(_res_ptr);
19014         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
19015         FREE((void*)_res);
19016         COption_u16Z_free(_res_conv);
19017 }
19018
19019 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
19020         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19021         *ret_copy = COption_u16Z_clone(arg);
19022 int64_t ret_ref = (uintptr_t)ret_copy;
19023         return ret_ref;
19024 }
19025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19026         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
19027         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
19028         return ret_conv;
19029 }
19030
19031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19032         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
19033         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19034         *ret_copy = COption_u16Z_clone(orig_conv);
19035         int64_t ret_ref = (uintptr_t)ret_copy;
19036         return ret_ref;
19037 }
19038
19039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
19040         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19041         *ret_conv = CResult_NoneAPIErrorZ_ok();
19042         return (int64_t)ret_conv;
19043 }
19044
19045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19046         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19047         CHECK_ACCESS(e_ptr);
19048         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19049         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19050         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19051         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
19052         return (int64_t)ret_conv;
19053 }
19054
19055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19056         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
19057         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
19058         return ret_conv;
19059 }
19060
19061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19062         if ((_res & 1) != 0) return;
19063         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19064         CHECK_ACCESS(_res_ptr);
19065         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
19066         FREE((void*)_res);
19067         CResult_NoneAPIErrorZ_free(_res_conv);
19068 }
19069
19070 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
19071         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19072         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
19073         return (int64_t)ret_conv;
19074 }
19075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19076         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
19077         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
19078         return ret_conv;
19079 }
19080
19081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19082         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
19083         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19084         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
19085         return (int64_t)ret_conv;
19086 }
19087
19088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19089         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
19090         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19091         if (_res_constr.datalen > 0)
19092                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
19093         else
19094                 _res_constr.data = NULL;
19095         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19096         for (size_t w = 0; w < _res_constr.datalen; w++) {
19097                 int64_t _res_conv_22 = _res_vals[w];
19098                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
19099                 CHECK_ACCESS(_res_conv_22_ptr);
19100                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
19101                 FREE((void*)_res_conv_22);
19102                 _res_constr.data[w] = _res_conv_22_conv;
19103         }
19104         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19105         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
19106 }
19107
19108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19109         LDKCVec_APIErrorZ _res_constr;
19110         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19111         if (_res_constr.datalen > 0)
19112                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
19113         else
19114                 _res_constr.data = NULL;
19115         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19116         for (size_t k = 0; k < _res_constr.datalen; k++) {
19117                 int64_t _res_conv_10 = _res_vals[k];
19118                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
19119                 CHECK_ACCESS(_res_conv_10_ptr);
19120                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
19121                 FREE((void*)_res_conv_10);
19122                 _res_constr.data[k] = _res_conv_10_conv;
19123         }
19124         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19125         CVec_APIErrorZ_free(_res_constr);
19126 }
19127
19128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19129         LDKThirtyTwoBytes o_ref;
19130         CHECK((*env)->GetArrayLength(env, o) == 32);
19131         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19132         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19133         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
19134         return (int64_t)ret_conv;
19135 }
19136
19137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19138         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19139         CHECK_ACCESS(e_ptr);
19140         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19141         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19142         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19143         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
19144         return (int64_t)ret_conv;
19145 }
19146
19147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19148         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
19149         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
19150         return ret_conv;
19151 }
19152
19153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19154         if ((_res & 1) != 0) return;
19155         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19156         CHECK_ACCESS(_res_ptr);
19157         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
19158         FREE((void*)_res);
19159         CResult__u832APIErrorZ_free(_res_conv);
19160 }
19161
19162 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
19163         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19164         *ret_conv = CResult__u832APIErrorZ_clone(arg);
19165         return (int64_t)ret_conv;
19166 }
19167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19168         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
19169         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
19170         return ret_conv;
19171 }
19172
19173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19174         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
19175         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19176         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
19177         return (int64_t)ret_conv;
19178 }
19179
19180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19181         LDKThirtyTwoBytes o_ref;
19182         CHECK((*env)->GetArrayLength(env, o) == 32);
19183         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19184         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19185         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
19186         return (int64_t)ret_conv;
19187 }
19188
19189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19190         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19191         CHECK_ACCESS(e_ptr);
19192         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19193         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19194         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19195         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
19196         return (int64_t)ret_conv;
19197 }
19198
19199 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19200         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
19201         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
19202         return ret_conv;
19203 }
19204
19205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19206         if ((_res & 1) != 0) return;
19207         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19208         CHECK_ACCESS(_res_ptr);
19209         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
19210         FREE((void*)_res);
19211         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
19212 }
19213
19214 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
19215         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19216         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
19217         return (int64_t)ret_conv;
19218 }
19219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19220         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
19221         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
19222         return ret_conv;
19223 }
19224
19225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19226         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
19227         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
19228         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
19229         return (int64_t)ret_conv;
19230 }
19231
19232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
19233         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19234         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
19235         return (int64_t)ret_conv;
19236 }
19237
19238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19239         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19240         CHECK_ACCESS(e_ptr);
19241         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19242         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19243         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19244         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
19245         return (int64_t)ret_conv;
19246 }
19247
19248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19249         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
19250         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
19251         return ret_conv;
19252 }
19253
19254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19255         if ((_res & 1) != 0) return;
19256         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19257         CHECK_ACCESS(_res_ptr);
19258         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
19259         FREE((void*)_res);
19260         CResult_NonePaymentSendFailureZ_free(_res_conv);
19261 }
19262
19263 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
19264         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19265         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
19266         return (int64_t)ret_conv;
19267 }
19268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19269         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
19270         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
19271         return ret_conv;
19272 }
19273
19274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19275         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
19276         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
19277         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
19278         return (int64_t)ret_conv;
19279 }
19280
19281 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
19282         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19283         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
19284         return ((int64_t)ret_conv);
19285 }
19286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19287         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
19288         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
19289         return ret_conv;
19290 }
19291
19292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19293         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
19294         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19295         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
19296         return ((int64_t)ret_conv);
19297 }
19298
19299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19300         LDKThirtyTwoBytes a_ref;
19301         CHECK((*env)->GetArrayLength(env, a) == 32);
19302         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19303         LDKThirtyTwoBytes b_ref;
19304         CHECK((*env)->GetArrayLength(env, b) == 32);
19305         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19306         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
19307         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
19308         return ((int64_t)ret_conv);
19309 }
19310
19311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19312         if ((_res & 1) != 0) return;
19313         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19314         CHECK_ACCESS(_res_ptr);
19315         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
19316         FREE((void*)_res);
19317         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
19318 }
19319
19320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19321         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19322         CHECK_ACCESS(o_ptr);
19323         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
19324         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
19325         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19326         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
19327         return (int64_t)ret_conv;
19328 }
19329
19330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19331         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19332         CHECK_ACCESS(e_ptr);
19333         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
19334         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
19335         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19336         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
19337         return (int64_t)ret_conv;
19338 }
19339
19340 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19341         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
19342         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
19343         return ret_conv;
19344 }
19345
19346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19347         if ((_res & 1) != 0) return;
19348         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19349         CHECK_ACCESS(_res_ptr);
19350         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
19351         FREE((void*)_res);
19352         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
19353 }
19354
19355 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
19356         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19357         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
19358         return (int64_t)ret_conv;
19359 }
19360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19361         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
19362         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
19363         return ret_conv;
19364 }
19365
19366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19367         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
19368         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
19369         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
19370         return (int64_t)ret_conv;
19371 }
19372
19373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19374         LDKCVec_ThirtyTwoBytesZ _res_constr;
19375         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19376         if (_res_constr.datalen > 0)
19377                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
19378         else
19379                 _res_constr.data = NULL;
19380         for (size_t i = 0; i < _res_constr.datalen; i++) {
19381                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19382                 LDKThirtyTwoBytes _res_conv_8_ref;
19383                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19384                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19385                 _res_constr.data[i] = _res_conv_8_ref;
19386         }
19387         CVec_ThirtyTwoBytesZ_free(_res_constr);
19388 }
19389
19390 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
19391         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19392         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
19393         return ((int64_t)ret_conv);
19394 }
19395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19396         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
19397         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
19398         return ret_conv;
19399 }
19400
19401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19402         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
19403         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19404         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
19405         return ((int64_t)ret_conv);
19406 }
19407
19408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19409         LDKThirtyTwoBytes a_ref;
19410         CHECK((*env)->GetArrayLength(env, a) == 32);
19411         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19412         LDKThirtyTwoBytes b_ref;
19413         CHECK((*env)->GetArrayLength(env, b) == 32);
19414         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19415         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
19416         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
19417         return ((int64_t)ret_conv);
19418 }
19419
19420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19421         if ((_res & 1) != 0) return;
19422         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19423         CHECK_ACCESS(_res_ptr);
19424         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
19425         FREE((void*)_res);
19426         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
19427 }
19428
19429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19430         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19431         CHECK_ACCESS(o_ptr);
19432         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19433         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19434         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19435         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
19436         return (int64_t)ret_conv;
19437 }
19438
19439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
19440         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19441         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
19442         return (int64_t)ret_conv;
19443 }
19444
19445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19446         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
19447         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
19448         return ret_conv;
19449 }
19450
19451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19452         if ((_res & 1) != 0) return;
19453         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19454         CHECK_ACCESS(_res_ptr);
19455         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
19456         FREE((void*)_res);
19457         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
19458 }
19459
19460 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
19461         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19462         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
19463         return (int64_t)ret_conv;
19464 }
19465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19466         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
19467         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
19468         return ret_conv;
19469 }
19470
19471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19472         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
19473         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
19474         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
19475         return (int64_t)ret_conv;
19476 }
19477
19478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19479         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19480         CHECK_ACCESS(o_ptr);
19481         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
19482         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
19483         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19484         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
19485         return (int64_t)ret_conv;
19486 }
19487
19488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19489         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19490         CHECK_ACCESS(e_ptr);
19491         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19492         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19493         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19494         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
19495         return (int64_t)ret_conv;
19496 }
19497
19498 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19499         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
19500         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
19501         return ret_conv;
19502 }
19503
19504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19505         if ((_res & 1) != 0) return;
19506         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19507         CHECK_ACCESS(_res_ptr);
19508         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
19509         FREE((void*)_res);
19510         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
19511 }
19512
19513 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
19514         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19515         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
19516         return (int64_t)ret_conv;
19517 }
19518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19519         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
19520         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
19521         return ret_conv;
19522 }
19523
19524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19525         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
19526         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
19527         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
19528         return (int64_t)ret_conv;
19529 }
19530
19531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19532         LDKThirtyTwoBytes o_ref;
19533         CHECK((*env)->GetArrayLength(env, o) == 32);
19534         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19535         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19536         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
19537         return (int64_t)ret_conv;
19538 }
19539
19540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
19541         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19542         *ret_conv = CResult_PaymentSecretNoneZ_err();
19543         return (int64_t)ret_conv;
19544 }
19545
19546 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19547         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
19548         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
19549         return ret_conv;
19550 }
19551
19552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19553         if ((_res & 1) != 0) return;
19554         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19555         CHECK_ACCESS(_res_ptr);
19556         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
19557         FREE((void*)_res);
19558         CResult_PaymentSecretNoneZ_free(_res_conv);
19559 }
19560
19561 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
19562         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19563         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
19564         return (int64_t)ret_conv;
19565 }
19566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19567         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
19568         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
19569         return ret_conv;
19570 }
19571
19572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19573         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
19574         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
19575         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
19576         return (int64_t)ret_conv;
19577 }
19578
19579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19580         LDKThirtyTwoBytes o_ref;
19581         CHECK((*env)->GetArrayLength(env, o) == 32);
19582         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19583         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19584         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
19585         return (int64_t)ret_conv;
19586 }
19587
19588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19589         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19590         CHECK_ACCESS(e_ptr);
19591         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19592         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19593         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19594         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
19595         return (int64_t)ret_conv;
19596 }
19597
19598 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19599         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
19600         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
19601         return ret_conv;
19602 }
19603
19604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19605         if ((_res & 1) != 0) return;
19606         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19607         CHECK_ACCESS(_res_ptr);
19608         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
19609         FREE((void*)_res);
19610         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
19611 }
19612
19613 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
19614         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19615         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
19616         return (int64_t)ret_conv;
19617 }
19618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19619         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
19620         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
19621         return ret_conv;
19622 }
19623
19624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19625         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
19626         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
19627         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
19628         return (int64_t)ret_conv;
19629 }
19630
19631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19632         LDKThirtyTwoBytes o_ref;
19633         CHECK((*env)->GetArrayLength(env, o) == 32);
19634         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19635         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19636         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
19637         return (int64_t)ret_conv;
19638 }
19639
19640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19641         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19642         CHECK_ACCESS(e_ptr);
19643         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19644         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
19645         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19646         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
19647         return (int64_t)ret_conv;
19648 }
19649
19650 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19651         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
19652         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
19653         return ret_conv;
19654 }
19655
19656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19657         if ((_res & 1) != 0) return;
19658         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19659         CHECK_ACCESS(_res_ptr);
19660         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
19661         FREE((void*)_res);
19662         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
19663 }
19664
19665 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
19666         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19667         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
19668         return (int64_t)ret_conv;
19669 }
19670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19671         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
19672         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
19673         return ret_conv;
19674 }
19675
19676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19677         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
19678         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
19679         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
19680         return (int64_t)ret_conv;
19681 }
19682
19683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19684         LDKCounterpartyForwardingInfo o_conv;
19685         o_conv.inner = (void*)(o & (~1));
19686         o_conv.is_owned = (o & 1) || (o == 0);
19687         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19688         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
19689         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19690         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
19691         return (int64_t)ret_conv;
19692 }
19693
19694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19695         LDKDecodeError e_conv;
19696         e_conv.inner = (void*)(e & (~1));
19697         e_conv.is_owned = (e & 1) || (e == 0);
19698         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19699         e_conv = DecodeError_clone(&e_conv);
19700         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19701         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
19702         return (int64_t)ret_conv;
19703 }
19704
19705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19706         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
19707         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
19708         return ret_conv;
19709 }
19710
19711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19712         if ((_res & 1) != 0) return;
19713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19714         CHECK_ACCESS(_res_ptr);
19715         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
19716         FREE((void*)_res);
19717         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
19718 }
19719
19720 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
19721         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19722         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
19723         return (int64_t)ret_conv;
19724 }
19725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19726         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
19727         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
19728         return ret_conv;
19729 }
19730
19731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19732         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
19733         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
19734         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
19735         return (int64_t)ret_conv;
19736 }
19737
19738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19739         LDKChannelCounterparty o_conv;
19740         o_conv.inner = (void*)(o & (~1));
19741         o_conv.is_owned = (o & 1) || (o == 0);
19742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19743         o_conv = ChannelCounterparty_clone(&o_conv);
19744         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19745         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
19746         return (int64_t)ret_conv;
19747 }
19748
19749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19750         LDKDecodeError e_conv;
19751         e_conv.inner = (void*)(e & (~1));
19752         e_conv.is_owned = (e & 1) || (e == 0);
19753         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19754         e_conv = DecodeError_clone(&e_conv);
19755         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19756         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
19757         return (int64_t)ret_conv;
19758 }
19759
19760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19761         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
19762         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
19763         return ret_conv;
19764 }
19765
19766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19767         if ((_res & 1) != 0) return;
19768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19769         CHECK_ACCESS(_res_ptr);
19770         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
19771         FREE((void*)_res);
19772         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
19773 }
19774
19775 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
19776         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19777         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
19778         return (int64_t)ret_conv;
19779 }
19780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19781         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
19782         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
19783         return ret_conv;
19784 }
19785
19786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19787         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
19788         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
19789         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
19790         return (int64_t)ret_conv;
19791 }
19792
19793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19794         LDKChannelDetails o_conv;
19795         o_conv.inner = (void*)(o & (~1));
19796         o_conv.is_owned = (o & 1) || (o == 0);
19797         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19798         o_conv = ChannelDetails_clone(&o_conv);
19799         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19800         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
19801         return (int64_t)ret_conv;
19802 }
19803
19804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19805         LDKDecodeError e_conv;
19806         e_conv.inner = (void*)(e & (~1));
19807         e_conv.is_owned = (e & 1) || (e == 0);
19808         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19809         e_conv = DecodeError_clone(&e_conv);
19810         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19811         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
19812         return (int64_t)ret_conv;
19813 }
19814
19815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19816         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
19817         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
19818         return ret_conv;
19819 }
19820
19821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19822         if ((_res & 1) != 0) return;
19823         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19824         CHECK_ACCESS(_res_ptr);
19825         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
19826         FREE((void*)_res);
19827         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
19828 }
19829
19830 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
19831         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19832         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
19833         return (int64_t)ret_conv;
19834 }
19835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19836         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
19837         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
19838         return ret_conv;
19839 }
19840
19841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19842         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
19843         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
19844         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
19845         return (int64_t)ret_conv;
19846 }
19847
19848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19849         LDKPhantomRouteHints o_conv;
19850         o_conv.inner = (void*)(o & (~1));
19851         o_conv.is_owned = (o & 1) || (o == 0);
19852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19853         o_conv = PhantomRouteHints_clone(&o_conv);
19854         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19855         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
19856         return (int64_t)ret_conv;
19857 }
19858
19859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19860         LDKDecodeError e_conv;
19861         e_conv.inner = (void*)(e & (~1));
19862         e_conv.is_owned = (e & 1) || (e == 0);
19863         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19864         e_conv = DecodeError_clone(&e_conv);
19865         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19866         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
19867         return (int64_t)ret_conv;
19868 }
19869
19870 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19871         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
19872         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
19873         return ret_conv;
19874 }
19875
19876 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19877         if ((_res & 1) != 0) return;
19878         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19879         CHECK_ACCESS(_res_ptr);
19880         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
19881         FREE((void*)_res);
19882         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
19883 }
19884
19885 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
19886         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19887         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
19888         return (int64_t)ret_conv;
19889 }
19890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19891         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
19892         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
19893         return ret_conv;
19894 }
19895
19896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19897         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
19898         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
19899         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
19900         return (int64_t)ret_conv;
19901 }
19902
19903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19904         LDKCVec_ChannelMonitorZ _res_constr;
19905         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19906         if (_res_constr.datalen > 0)
19907                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
19908         else
19909                 _res_constr.data = NULL;
19910         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19911         for (size_t q = 0; q < _res_constr.datalen; q++) {
19912                 int64_t _res_conv_16 = _res_vals[q];
19913                 LDKChannelMonitor _res_conv_16_conv;
19914                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
19915                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
19916                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
19917                 _res_constr.data[q] = _res_conv_16_conv;
19918         }
19919         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19920         CVec_ChannelMonitorZ_free(_res_constr);
19921 }
19922
19923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
19924         LDKThirtyTwoBytes a_ref;
19925         CHECK((*env)->GetArrayLength(env, a) == 32);
19926         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19927         LDKChannelManager b_conv;
19928         b_conv.inner = (void*)(b & (~1));
19929         b_conv.is_owned = (b & 1) || (b == 0);
19930         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19931         // WARNING: we need a move here but no clone is available for LDKChannelManager
19932         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
19933         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
19934         return ((int64_t)ret_conv);
19935 }
19936
19937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19938         if ((_res & 1) != 0) return;
19939         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19940         CHECK_ACCESS(_res_ptr);
19941         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
19942         FREE((void*)_res);
19943         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
19944 }
19945
19946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19947         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19948         CHECK_ACCESS(o_ptr);
19949         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
19950         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
19951         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
19952         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
19953         return (int64_t)ret_conv;
19954 }
19955
19956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19957         LDKDecodeError e_conv;
19958         e_conv.inner = (void*)(e & (~1));
19959         e_conv.is_owned = (e & 1) || (e == 0);
19960         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19961         e_conv = DecodeError_clone(&e_conv);
19962         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
19963         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
19964         return (int64_t)ret_conv;
19965 }
19966
19967 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19968         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
19969         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
19970         return ret_conv;
19971 }
19972
19973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19974         if ((_res & 1) != 0) return;
19975         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19976         CHECK_ACCESS(_res_ptr);
19977         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
19978         FREE((void*)_res);
19979         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
19980 }
19981
19982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19983         LDKChannelConfig o_conv;
19984         o_conv.inner = (void*)(o & (~1));
19985         o_conv.is_owned = (o & 1) || (o == 0);
19986         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19987         o_conv = ChannelConfig_clone(&o_conv);
19988         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
19989         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
19990         return (int64_t)ret_conv;
19991 }
19992
19993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19994         LDKDecodeError e_conv;
19995         e_conv.inner = (void*)(e & (~1));
19996         e_conv.is_owned = (e & 1) || (e == 0);
19997         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19998         e_conv = DecodeError_clone(&e_conv);
19999         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20000         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
20001         return (int64_t)ret_conv;
20002 }
20003
20004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20005         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
20006         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
20007         return ret_conv;
20008 }
20009
20010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20011         if ((_res & 1) != 0) return;
20012         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20013         CHECK_ACCESS(_res_ptr);
20014         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
20015         FREE((void*)_res);
20016         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
20017 }
20018
20019 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
20020         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20021         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
20022         return (int64_t)ret_conv;
20023 }
20024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20025         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
20026         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
20027         return ret_conv;
20028 }
20029
20030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20031         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
20032         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20033         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
20034         return (int64_t)ret_conv;
20035 }
20036
20037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20038         LDKOutPoint o_conv;
20039         o_conv.inner = (void*)(o & (~1));
20040         o_conv.is_owned = (o & 1) || (o == 0);
20041         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20042         o_conv = OutPoint_clone(&o_conv);
20043         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20044         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
20045         return (int64_t)ret_conv;
20046 }
20047
20048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20049         LDKDecodeError e_conv;
20050         e_conv.inner = (void*)(e & (~1));
20051         e_conv.is_owned = (e & 1) || (e == 0);
20052         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20053         e_conv = DecodeError_clone(&e_conv);
20054         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20055         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
20056         return (int64_t)ret_conv;
20057 }
20058
20059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20060         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
20061         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
20062         return ret_conv;
20063 }
20064
20065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20066         if ((_res & 1) != 0) return;
20067         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20068         CHECK_ACCESS(_res_ptr);
20069         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
20070         FREE((void*)_res);
20071         CResult_OutPointDecodeErrorZ_free(_res_conv);
20072 }
20073
20074 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
20075         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20076         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
20077         return (int64_t)ret_conv;
20078 }
20079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20080         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
20081         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
20082         return ret_conv;
20083 }
20084
20085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20086         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
20087         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20088         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
20089         return (int64_t)ret_conv;
20090 }
20091
20092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20093         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20094         CHECK_ACCESS(o_ptr);
20095         LDKType o_conv = *(LDKType*)(o_ptr);
20096         if (o_conv.free == LDKType_JCalls_free) {
20097                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20098                 LDKType_JCalls_cloned(&o_conv);
20099         }
20100         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20101         *ret_copy = COption_TypeZ_some(o_conv);
20102         int64_t ret_ref = (uintptr_t)ret_copy;
20103         return ret_ref;
20104 }
20105
20106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
20107         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20108         *ret_copy = COption_TypeZ_none();
20109         int64_t ret_ref = (uintptr_t)ret_copy;
20110         return ret_ref;
20111 }
20112
20113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20114         if ((_res & 1) != 0) return;
20115         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20116         CHECK_ACCESS(_res_ptr);
20117         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
20118         FREE((void*)_res);
20119         COption_TypeZ_free(_res_conv);
20120 }
20121
20122 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
20123         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20124         *ret_copy = COption_TypeZ_clone(arg);
20125 int64_t ret_ref = (uintptr_t)ret_copy;
20126         return ret_ref;
20127 }
20128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20129         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
20130         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
20131         return ret_conv;
20132 }
20133
20134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20135         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
20136         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20137         *ret_copy = COption_TypeZ_clone(orig_conv);
20138         int64_t ret_ref = (uintptr_t)ret_copy;
20139         return ret_ref;
20140 }
20141
20142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20143         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20144         CHECK_ACCESS(o_ptr);
20145         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
20146         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
20147         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20148         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
20149         return (int64_t)ret_conv;
20150 }
20151
20152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20153         LDKDecodeError e_conv;
20154         e_conv.inner = (void*)(e & (~1));
20155         e_conv.is_owned = (e & 1) || (e == 0);
20156         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20157         e_conv = DecodeError_clone(&e_conv);
20158         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20159         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
20160         return (int64_t)ret_conv;
20161 }
20162
20163 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20164         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
20165         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
20166         return ret_conv;
20167 }
20168
20169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20170         if ((_res & 1) != 0) return;
20171         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20172         CHECK_ACCESS(_res_ptr);
20173         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
20174         FREE((void*)_res);
20175         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
20176 }
20177
20178 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
20179         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20180         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
20181         return (int64_t)ret_conv;
20182 }
20183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20184         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
20185         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
20186         return ret_conv;
20187 }
20188
20189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20190         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
20191         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20192         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
20193         return (int64_t)ret_conv;
20194 }
20195
20196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20197         LDKThirtyTwoBytes o_ref;
20198         CHECK((*env)->GetArrayLength(env, o) == 32);
20199         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20200         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20201         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
20202         return (int64_t)ret_conv;
20203 }
20204
20205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20206         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20207         CHECK_ACCESS(e_ptr);
20208         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
20209         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
20210         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20211         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
20212         return (int64_t)ret_conv;
20213 }
20214
20215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20216         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
20217         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
20218         return ret_conv;
20219 }
20220
20221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20222         if ((_res & 1) != 0) return;
20223         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20224         CHECK_ACCESS(_res_ptr);
20225         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
20226         FREE((void*)_res);
20227         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
20228 }
20229
20230 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
20231         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20232         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
20233         return (int64_t)ret_conv;
20234 }
20235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20236         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
20237         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
20238         return ret_conv;
20239 }
20240
20241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20242         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
20243         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
20244         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
20245         return (int64_t)ret_conv;
20246 }
20247
20248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
20249         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
20250         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20251         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
20252         return (int64_t)ret_conv;
20253 }
20254
20255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20256         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20257         CHECK_ACCESS(e_ptr);
20258         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
20259         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
20260         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20261         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
20262         return (int64_t)ret_conv;
20263 }
20264
20265 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20266         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
20267         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
20268         return ret_conv;
20269 }
20270
20271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20272         if ((_res & 1) != 0) return;
20273         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20274         CHECK_ACCESS(_res_ptr);
20275         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
20276         FREE((void*)_res);
20277         CResult_SiPrefixParseErrorZ_free(_res_conv);
20278 }
20279
20280 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
20281         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20282         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
20283         return (int64_t)ret_conv;
20284 }
20285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20286         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
20287         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
20288         return ret_conv;
20289 }
20290
20291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20292         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
20293         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
20294         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
20295         return (int64_t)ret_conv;
20296 }
20297
20298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20299         LDKInvoice o_conv;
20300         o_conv.inner = (void*)(o & (~1));
20301         o_conv.is_owned = (o & 1) || (o == 0);
20302         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20303         o_conv = Invoice_clone(&o_conv);
20304         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20305         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
20306         return (int64_t)ret_conv;
20307 }
20308
20309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20310         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20311         CHECK_ACCESS(e_ptr);
20312         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
20313         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
20314         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20315         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
20316         return (int64_t)ret_conv;
20317 }
20318
20319 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20320         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
20321         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
20322         return ret_conv;
20323 }
20324
20325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20326         if ((_res & 1) != 0) return;
20327         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20328         CHECK_ACCESS(_res_ptr);
20329         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
20330         FREE((void*)_res);
20331         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
20332 }
20333
20334 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
20335         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20336         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
20337         return (int64_t)ret_conv;
20338 }
20339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20340         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
20341         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
20342         return ret_conv;
20343 }
20344
20345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20346         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
20347         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
20348         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
20349         return (int64_t)ret_conv;
20350 }
20351
20352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20353         LDKSignedRawInvoice o_conv;
20354         o_conv.inner = (void*)(o & (~1));
20355         o_conv.is_owned = (o & 1) || (o == 0);
20356         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20357         o_conv = SignedRawInvoice_clone(&o_conv);
20358         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20359         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
20360         return (int64_t)ret_conv;
20361 }
20362
20363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20364         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
20365         CHECK_ACCESS(e_ptr);
20366         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
20367         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
20368         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20369         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
20370         return (int64_t)ret_conv;
20371 }
20372
20373 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20374         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
20375         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
20376         return ret_conv;
20377 }
20378
20379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20380         if ((_res & 1) != 0) return;
20381         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20382         CHECK_ACCESS(_res_ptr);
20383         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
20384         FREE((void*)_res);
20385         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
20386 }
20387
20388 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
20389         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20390         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
20391         return (int64_t)ret_conv;
20392 }
20393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20394         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
20395         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
20396         return ret_conv;
20397 }
20398
20399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20400         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
20401         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
20402         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
20403         return (int64_t)ret_conv;
20404 }
20405
20406 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
20407         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20408         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
20409         return ((int64_t)ret_conv);
20410 }
20411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20412         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
20413         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
20414         return ret_conv;
20415 }
20416
20417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20418         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
20419         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20420         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
20421         return ((int64_t)ret_conv);
20422 }
20423
20424 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) {
20425         LDKRawInvoice a_conv;
20426         a_conv.inner = (void*)(a & (~1));
20427         a_conv.is_owned = (a & 1) || (a == 0);
20428         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20429         a_conv = RawInvoice_clone(&a_conv);
20430         LDKThirtyTwoBytes b_ref;
20431         CHECK((*env)->GetArrayLength(env, b) == 32);
20432         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20433         LDKInvoiceSignature c_conv;
20434         c_conv.inner = (void*)(c & (~1));
20435         c_conv.is_owned = (c & 1) || (c == 0);
20436         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
20437         c_conv = InvoiceSignature_clone(&c_conv);
20438         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
20439         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
20440         return ((int64_t)ret_conv);
20441 }
20442
20443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20444         if ((_res & 1) != 0) return;
20445         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20446         CHECK_ACCESS(_res_ptr);
20447         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
20448         FREE((void*)_res);
20449         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
20450 }
20451
20452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20453         LDKPayeePubKey o_conv;
20454         o_conv.inner = (void*)(o & (~1));
20455         o_conv.is_owned = (o & 1) || (o == 0);
20456         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20457         o_conv = PayeePubKey_clone(&o_conv);
20458         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20459         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
20460         return (int64_t)ret_conv;
20461 }
20462
20463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20464         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
20465         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20466         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
20467         return (int64_t)ret_conv;
20468 }
20469
20470 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20471         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
20472         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
20473         return ret_conv;
20474 }
20475
20476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20477         if ((_res & 1) != 0) return;
20478         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20479         CHECK_ACCESS(_res_ptr);
20480         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
20481         FREE((void*)_res);
20482         CResult_PayeePubKeyErrorZ_free(_res_conv);
20483 }
20484
20485 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
20486         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20487         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
20488         return (int64_t)ret_conv;
20489 }
20490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20491         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
20492         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
20493         return ret_conv;
20494 }
20495
20496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20497         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
20498         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
20499         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
20500         return (int64_t)ret_conv;
20501 }
20502
20503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20504         LDKCVec_PrivateRouteZ _res_constr;
20505         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20506         if (_res_constr.datalen > 0)
20507                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
20508         else
20509                 _res_constr.data = NULL;
20510         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20511         for (size_t o = 0; o < _res_constr.datalen; o++) {
20512                 int64_t _res_conv_14 = _res_vals[o];
20513                 LDKPrivateRoute _res_conv_14_conv;
20514                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
20515                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
20516                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
20517                 _res_constr.data[o] = _res_conv_14_conv;
20518         }
20519         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20520         CVec_PrivateRouteZ_free(_res_constr);
20521 }
20522
20523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20524         LDKPositiveTimestamp o_conv;
20525         o_conv.inner = (void*)(o & (~1));
20526         o_conv.is_owned = (o & 1) || (o == 0);
20527         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20528         o_conv = PositiveTimestamp_clone(&o_conv);
20529         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20530         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
20531         return (int64_t)ret_conv;
20532 }
20533
20534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20535         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20536         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20537         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
20538         return (int64_t)ret_conv;
20539 }
20540
20541 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20542         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
20543         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
20544         return ret_conv;
20545 }
20546
20547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20548         if ((_res & 1) != 0) return;
20549         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20550         CHECK_ACCESS(_res_ptr);
20551         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
20552         FREE((void*)_res);
20553         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
20554 }
20555
20556 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
20557         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20558         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
20559         return (int64_t)ret_conv;
20560 }
20561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20562         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
20563         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
20564         return ret_conv;
20565 }
20566
20567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20568         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
20569         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
20570         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
20571         return (int64_t)ret_conv;
20572 }
20573
20574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
20575         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20576         *ret_conv = CResult_NoneSemanticErrorZ_ok();
20577         return (int64_t)ret_conv;
20578 }
20579
20580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20581         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
20582         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20583         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
20584         return (int64_t)ret_conv;
20585 }
20586
20587 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20588         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
20589         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
20590         return ret_conv;
20591 }
20592
20593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20594         if ((_res & 1) != 0) return;
20595         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20596         CHECK_ACCESS(_res_ptr);
20597         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
20598         FREE((void*)_res);
20599         CResult_NoneSemanticErrorZ_free(_res_conv);
20600 }
20601
20602 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
20603         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20604         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
20605         return (int64_t)ret_conv;
20606 }
20607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20608         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
20609         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
20610         return ret_conv;
20611 }
20612
20613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20614         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
20615         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
20616         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
20617         return (int64_t)ret_conv;
20618 }
20619
20620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20621         LDKInvoice o_conv;
20622         o_conv.inner = (void*)(o & (~1));
20623         o_conv.is_owned = (o & 1) || (o == 0);
20624         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20625         o_conv = Invoice_clone(&o_conv);
20626         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20627         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
20628         return (int64_t)ret_conv;
20629 }
20630
20631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20632         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
20633         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20634         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
20635         return (int64_t)ret_conv;
20636 }
20637
20638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20639         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
20640         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
20641         return ret_conv;
20642 }
20643
20644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20645         if ((_res & 1) != 0) return;
20646         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20647         CHECK_ACCESS(_res_ptr);
20648         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
20649         FREE((void*)_res);
20650         CResult_InvoiceSemanticErrorZ_free(_res_conv);
20651 }
20652
20653 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
20654         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20655         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
20656         return (int64_t)ret_conv;
20657 }
20658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20659         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
20660         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
20661         return ret_conv;
20662 }
20663
20664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20665         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
20666         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
20667         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
20668         return (int64_t)ret_conv;
20669 }
20670
20671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20672         LDKDescription o_conv;
20673         o_conv.inner = (void*)(o & (~1));
20674         o_conv.is_owned = (o & 1) || (o == 0);
20675         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20676         o_conv = Description_clone(&o_conv);
20677         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20678         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
20679         return (int64_t)ret_conv;
20680 }
20681
20682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20683         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20684         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20685         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
20686         return (int64_t)ret_conv;
20687 }
20688
20689 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20690         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
20691         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
20692         return ret_conv;
20693 }
20694
20695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20696         if ((_res & 1) != 0) return;
20697         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20698         CHECK_ACCESS(_res_ptr);
20699         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
20700         FREE((void*)_res);
20701         CResult_DescriptionCreationErrorZ_free(_res_conv);
20702 }
20703
20704 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
20705         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20706         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
20707         return (int64_t)ret_conv;
20708 }
20709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20710         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
20711         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
20712         return ret_conv;
20713 }
20714
20715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20716         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
20717         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
20718         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
20719         return (int64_t)ret_conv;
20720 }
20721
20722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20723         LDKPrivateRoute o_conv;
20724         o_conv.inner = (void*)(o & (~1));
20725         o_conv.is_owned = (o & 1) || (o == 0);
20726         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20727         o_conv = PrivateRoute_clone(&o_conv);
20728         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20729         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
20730         return (int64_t)ret_conv;
20731 }
20732
20733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20734         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
20735         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20736         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
20737         return (int64_t)ret_conv;
20738 }
20739
20740 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20741         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
20742         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
20743         return ret_conv;
20744 }
20745
20746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20747         if ((_res & 1) != 0) return;
20748         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20749         CHECK_ACCESS(_res_ptr);
20750         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
20751         FREE((void*)_res);
20752         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
20753 }
20754
20755 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
20756         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20757         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
20758         return (int64_t)ret_conv;
20759 }
20760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20761         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
20762         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
20763         return ret_conv;
20764 }
20765
20766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20767         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
20768         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
20769         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
20770         return (int64_t)ret_conv;
20771 }
20772
20773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
20774         LDKStr o_conv = java_to_owned_str(env, o);
20775         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20776         *ret_conv = CResult_StringErrorZ_ok(o_conv);
20777         return (int64_t)ret_conv;
20778 }
20779
20780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20781         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
20782         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20783         *ret_conv = CResult_StringErrorZ_err(e_conv);
20784         return (int64_t)ret_conv;
20785 }
20786
20787 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20788         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
20789         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
20790         return ret_conv;
20791 }
20792
20793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20794         if ((_res & 1) != 0) return;
20795         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20796         CHECK_ACCESS(_res_ptr);
20797         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
20798         FREE((void*)_res);
20799         CResult_StringErrorZ_free(_res_conv);
20800 }
20801
20802 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
20803         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20804         *ret_conv = CResult_StringErrorZ_clone(arg);
20805         return (int64_t)ret_conv;
20806 }
20807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20808         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
20809         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
20810         return ret_conv;
20811 }
20812
20813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20814         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
20815         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20816         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
20817         return (int64_t)ret_conv;
20818 }
20819
20820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20821         LDKChannelMonitorUpdate o_conv;
20822         o_conv.inner = (void*)(o & (~1));
20823         o_conv.is_owned = (o & 1) || (o == 0);
20824         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20825         o_conv = ChannelMonitorUpdate_clone(&o_conv);
20826         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20827         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
20828         return (int64_t)ret_conv;
20829 }
20830
20831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20832         LDKDecodeError e_conv;
20833         e_conv.inner = (void*)(e & (~1));
20834         e_conv.is_owned = (e & 1) || (e == 0);
20835         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20836         e_conv = DecodeError_clone(&e_conv);
20837         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20838         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
20839         return (int64_t)ret_conv;
20840 }
20841
20842 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20843         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
20844         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
20845         return ret_conv;
20846 }
20847
20848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20849         if ((_res & 1) != 0) return;
20850         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20851         CHECK_ACCESS(_res_ptr);
20852         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
20853         FREE((void*)_res);
20854         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
20855 }
20856
20857 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
20858         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20859         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
20860         return (int64_t)ret_conv;
20861 }
20862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20863         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
20864         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
20865         return ret_conv;
20866 }
20867
20868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20869         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
20870         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
20871         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
20872         return (int64_t)ret_conv;
20873 }
20874
20875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20876         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20877         CHECK_ACCESS(o_ptr);
20878         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
20879         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
20880         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20881         *ret_copy = COption_MonitorEventZ_some(o_conv);
20882         int64_t ret_ref = (uintptr_t)ret_copy;
20883         return ret_ref;
20884 }
20885
20886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
20887         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20888         *ret_copy = COption_MonitorEventZ_none();
20889         int64_t ret_ref = (uintptr_t)ret_copy;
20890         return ret_ref;
20891 }
20892
20893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20894         if ((_res & 1) != 0) return;
20895         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20896         CHECK_ACCESS(_res_ptr);
20897         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
20898         FREE((void*)_res);
20899         COption_MonitorEventZ_free(_res_conv);
20900 }
20901
20902 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
20903         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20904         *ret_copy = COption_MonitorEventZ_clone(arg);
20905 int64_t ret_ref = (uintptr_t)ret_copy;
20906         return ret_ref;
20907 }
20908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20909         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
20910         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
20911         return ret_conv;
20912 }
20913
20914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20915         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
20916         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
20917         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
20918         int64_t ret_ref = (uintptr_t)ret_copy;
20919         return ret_ref;
20920 }
20921
20922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20923         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20924         CHECK_ACCESS(o_ptr);
20925         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
20926         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
20927         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20928         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
20929         return (int64_t)ret_conv;
20930 }
20931
20932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20933         LDKDecodeError e_conv;
20934         e_conv.inner = (void*)(e & (~1));
20935         e_conv.is_owned = (e & 1) || (e == 0);
20936         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20937         e_conv = DecodeError_clone(&e_conv);
20938         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20939         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
20940         return (int64_t)ret_conv;
20941 }
20942
20943 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20944         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
20945         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
20946         return ret_conv;
20947 }
20948
20949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20950         if ((_res & 1) != 0) return;
20951         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20952         CHECK_ACCESS(_res_ptr);
20953         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
20954         FREE((void*)_res);
20955         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
20956 }
20957
20958 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
20959         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20960         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
20961         return (int64_t)ret_conv;
20962 }
20963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20964         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
20965         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
20966         return ret_conv;
20967 }
20968
20969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20970         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
20971         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
20972         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
20973         return (int64_t)ret_conv;
20974 }
20975
20976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20977         LDKHTLCUpdate o_conv;
20978         o_conv.inner = (void*)(o & (~1));
20979         o_conv.is_owned = (o & 1) || (o == 0);
20980         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20981         o_conv = HTLCUpdate_clone(&o_conv);
20982         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20983         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
20984         return (int64_t)ret_conv;
20985 }
20986
20987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20988         LDKDecodeError e_conv;
20989         e_conv.inner = (void*)(e & (~1));
20990         e_conv.is_owned = (e & 1) || (e == 0);
20991         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20992         e_conv = DecodeError_clone(&e_conv);
20993         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
20994         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
20995         return (int64_t)ret_conv;
20996 }
20997
20998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20999         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
21000         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
21001         return ret_conv;
21002 }
21003
21004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21005         if ((_res & 1) != 0) return;
21006         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21007         CHECK_ACCESS(_res_ptr);
21008         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
21009         FREE((void*)_res);
21010         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
21011 }
21012
21013 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
21014         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21015         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
21016         return (int64_t)ret_conv;
21017 }
21018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21019         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
21020         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
21021         return ret_conv;
21022 }
21023
21024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21025         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
21026         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21027         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
21028         return (int64_t)ret_conv;
21029 }
21030
21031 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
21032         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21033         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
21034         return ((int64_t)ret_conv);
21035 }
21036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21037         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
21038         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
21039         return ret_conv;
21040 }
21041
21042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21043         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
21044         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21045         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
21046         return ((int64_t)ret_conv);
21047 }
21048
21049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
21050         LDKOutPoint a_conv;
21051         a_conv.inner = (void*)(a & (~1));
21052         a_conv.is_owned = (a & 1) || (a == 0);
21053         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21054         a_conv = OutPoint_clone(&a_conv);
21055         LDKCVec_u8Z b_ref;
21056         b_ref.datalen = (*env)->GetArrayLength(env, b);
21057         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21058         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21059         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21060         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
21061         return ((int64_t)ret_conv);
21062 }
21063
21064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21065         if ((_res & 1) != 0) return;
21066         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21067         CHECK_ACCESS(_res_ptr);
21068         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
21069         FREE((void*)_res);
21070         C2Tuple_OutPointScriptZ_free(_res_conv);
21071 }
21072
21073 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
21074         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21075         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
21076         return ((int64_t)ret_conv);
21077 }
21078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21079         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
21080         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
21081         return ret_conv;
21082 }
21083
21084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21085         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
21086         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21087         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
21088         return ((int64_t)ret_conv);
21089 }
21090
21091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
21092         LDKCVec_u8Z b_ref;
21093         b_ref.datalen = (*env)->GetArrayLength(env, b);
21094         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21095         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21096         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21097         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
21098         return ((int64_t)ret_conv);
21099 }
21100
21101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21102         if ((_res & 1) != 0) return;
21103         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21104         CHECK_ACCESS(_res_ptr);
21105         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
21106         FREE((void*)_res);
21107         C2Tuple_u32ScriptZ_free(_res_conv);
21108 }
21109
21110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21111         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
21112         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21113         if (_res_constr.datalen > 0)
21114                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
21115         else
21116                 _res_constr.data = NULL;
21117         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21118         for (size_t v = 0; v < _res_constr.datalen; v++) {
21119                 int64_t _res_conv_21 = _res_vals[v];
21120                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
21121                 CHECK_ACCESS(_res_conv_21_ptr);
21122                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
21123                 FREE((void*)_res_conv_21);
21124                 _res_constr.data[v] = _res_conv_21_conv;
21125         }
21126         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21127         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
21128 }
21129
21130 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
21131         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21132         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
21133         return ((int64_t)ret_conv);
21134 }
21135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21136         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
21137         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
21138         return ret_conv;
21139 }
21140
21141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21142         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
21143         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21144         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
21145         return ((int64_t)ret_conv);
21146 }
21147
21148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
21149         LDKThirtyTwoBytes a_ref;
21150         CHECK((*env)->GetArrayLength(env, a) == 32);
21151         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21152         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
21153         b_constr.datalen = (*env)->GetArrayLength(env, b);
21154         if (b_constr.datalen > 0)
21155                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
21156         else
21157                 b_constr.data = NULL;
21158         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
21159         for (size_t v = 0; v < b_constr.datalen; v++) {
21160                 int64_t b_conv_21 = b_vals[v];
21161                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
21162                 CHECK_ACCESS(b_conv_21_ptr);
21163                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
21164                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
21165                 b_constr.data[v] = b_conv_21_conv;
21166         }
21167         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
21168         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
21169         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
21170         return ((int64_t)ret_conv);
21171 }
21172
21173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21174         if ((_res & 1) != 0) return;
21175         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21176         CHECK_ACCESS(_res_ptr);
21177         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
21178         FREE((void*)_res);
21179         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
21180 }
21181
21182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21183         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
21184         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21185         if (_res_constr.datalen > 0)
21186                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
21187         else
21188                 _res_constr.data = NULL;
21189         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21190         for (size_t o = 0; o < _res_constr.datalen; o++) {
21191                 int64_t _res_conv_40 = _res_vals[o];
21192                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
21193                 CHECK_ACCESS(_res_conv_40_ptr);
21194                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
21195                 FREE((void*)_res_conv_40);
21196                 _res_constr.data[o] = _res_conv_40_conv;
21197         }
21198         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21199         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
21200 }
21201
21202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21203         LDKCVec_EventZ _res_constr;
21204         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21205         if (_res_constr.datalen > 0)
21206                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
21207         else
21208                 _res_constr.data = NULL;
21209         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21210         for (size_t h = 0; h < _res_constr.datalen; h++) {
21211                 int64_t _res_conv_7 = _res_vals[h];
21212                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
21213                 CHECK_ACCESS(_res_conv_7_ptr);
21214                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
21215                 FREE((void*)_res_conv_7);
21216                 _res_constr.data[h] = _res_conv_7_conv;
21217         }
21218         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21219         CVec_EventZ_free(_res_constr);
21220 }
21221
21222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21223         LDKCVec_TransactionZ _res_constr;
21224         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21225         if (_res_constr.datalen > 0)
21226                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
21227         else
21228                 _res_constr.data = NULL;
21229         for (size_t i = 0; i < _res_constr.datalen; i++) {
21230                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21231                 LDKTransaction _res_conv_8_ref;
21232                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
21233                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
21234                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
21235                 _res_conv_8_ref.data_is_owned = true;
21236                 _res_constr.data[i] = _res_conv_8_ref;
21237         }
21238         CVec_TransactionZ_free(_res_constr);
21239 }
21240
21241 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
21242         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21243         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
21244         return ((int64_t)ret_conv);
21245 }
21246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21247         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
21248         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
21249         return ret_conv;
21250 }
21251
21252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21253         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
21254         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21255         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
21256         return ((int64_t)ret_conv);
21257 }
21258
21259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
21260         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
21261         CHECK_ACCESS(b_ptr);
21262         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
21263         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
21264         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
21265         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
21266         return ((int64_t)ret_conv);
21267 }
21268
21269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21270         if ((_res & 1) != 0) return;
21271         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21272         CHECK_ACCESS(_res_ptr);
21273         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
21274         FREE((void*)_res);
21275         C2Tuple_u32TxOutZ_free(_res_conv);
21276 }
21277
21278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21279         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
21280         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21281         if (_res_constr.datalen > 0)
21282                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21283         else
21284                 _res_constr.data = NULL;
21285         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21286         for (size_t u = 0; u < _res_constr.datalen; u++) {
21287                 int64_t _res_conv_20 = _res_vals[u];
21288                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
21289                 CHECK_ACCESS(_res_conv_20_ptr);
21290                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
21291                 FREE((void*)_res_conv_20);
21292                 _res_constr.data[u] = _res_conv_20_conv;
21293         }
21294         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21295         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
21296 }
21297
21298 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
21299         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21300         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
21301         return ((int64_t)ret_conv);
21302 }
21303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21304         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
21305         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
21306         return ret_conv;
21307 }
21308
21309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21310         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
21311         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21312         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
21313         return ((int64_t)ret_conv);
21314 }
21315
21316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
21317         LDKThirtyTwoBytes a_ref;
21318         CHECK((*env)->GetArrayLength(env, a) == 32);
21319         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21320         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
21321         b_constr.datalen = (*env)->GetArrayLength(env, b);
21322         if (b_constr.datalen > 0)
21323                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
21324         else
21325                 b_constr.data = NULL;
21326         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
21327         for (size_t u = 0; u < b_constr.datalen; u++) {
21328                 int64_t b_conv_20 = b_vals[u];
21329                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
21330                 CHECK_ACCESS(b_conv_20_ptr);
21331                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
21332                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
21333                 b_constr.data[u] = b_conv_20_conv;
21334         }
21335         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
21336         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
21337         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
21338         return ((int64_t)ret_conv);
21339 }
21340
21341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21342         if ((_res & 1) != 0) return;
21343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21344         CHECK_ACCESS(_res_ptr);
21345         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
21346         FREE((void*)_res);
21347         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
21348 }
21349
21350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21351         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
21352         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21353         if (_res_constr.datalen > 0)
21354                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
21355         else
21356                 _res_constr.data = NULL;
21357         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21358         for (size_t n = 0; n < _res_constr.datalen; n++) {
21359                 int64_t _res_conv_39 = _res_vals[n];
21360                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
21361                 CHECK_ACCESS(_res_conv_39_ptr);
21362                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
21363                 FREE((void*)_res_conv_39);
21364                 _res_constr.data[n] = _res_conv_39_conv;
21365         }
21366         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21367         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
21368 }
21369
21370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21371         LDKCVec_BalanceZ _res_constr;
21372         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21373         if (_res_constr.datalen > 0)
21374                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
21375         else
21376                 _res_constr.data = NULL;
21377         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21378         for (size_t j = 0; j < _res_constr.datalen; j++) {
21379                 int64_t _res_conv_9 = _res_vals[j];
21380                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
21381                 CHECK_ACCESS(_res_conv_9_ptr);
21382                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
21383                 FREE((void*)_res_conv_9);
21384                 _res_constr.data[j] = _res_conv_9_conv;
21385         }
21386         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21387         CVec_BalanceZ_free(_res_constr);
21388 }
21389
21390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21391         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21392         CHECK_ACCESS(o_ptr);
21393         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
21394         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
21395         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21396         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
21397         return (int64_t)ret_conv;
21398 }
21399
21400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21401         LDKDecodeError e_conv;
21402         e_conv.inner = (void*)(e & (~1));
21403         e_conv.is_owned = (e & 1) || (e == 0);
21404         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21405         e_conv = DecodeError_clone(&e_conv);
21406         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21407         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
21408         return (int64_t)ret_conv;
21409 }
21410
21411 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21412         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
21413         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
21414         return ret_conv;
21415 }
21416
21417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21418         if ((_res & 1) != 0) return;
21419         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21420         CHECK_ACCESS(_res_ptr);
21421         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
21422         FREE((void*)_res);
21423         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
21424 }
21425
21426 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
21427         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21428         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
21429         return (int64_t)ret_conv;
21430 }
21431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21432         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
21433         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
21434         return ret_conv;
21435 }
21436
21437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21438         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
21439         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
21440         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
21441         return (int64_t)ret_conv;
21442 }
21443
21444 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
21445         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21446         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
21447         return ((int64_t)ret_conv);
21448 }
21449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21450         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
21451         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
21452         return ret_conv;
21453 }
21454
21455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21456         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
21457         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21458         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
21459         return ((int64_t)ret_conv);
21460 }
21461
21462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21463         LDKPublicKey a_ref;
21464         CHECK((*env)->GetArrayLength(env, a) == 33);
21465         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
21466         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
21467         CHECK_ACCESS(b_ptr);
21468         LDKType b_conv = *(LDKType*)(b_ptr);
21469         if (b_conv.free == LDKType_JCalls_free) {
21470                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21471                 LDKType_JCalls_cloned(&b_conv);
21472         }
21473         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
21474         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
21475         return ((int64_t)ret_conv);
21476 }
21477
21478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21479         if ((_res & 1) != 0) return;
21480         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21481         CHECK_ACCESS(_res_ptr);
21482         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
21483         FREE((void*)_res);
21484         C2Tuple_PublicKeyTypeZ_free(_res_conv);
21485 }
21486
21487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21488         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
21489         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21490         if (_res_constr.datalen > 0)
21491                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
21492         else
21493                 _res_constr.data = NULL;
21494         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21495         for (size_t z = 0; z < _res_constr.datalen; z++) {
21496                 int64_t _res_conv_25 = _res_vals[z];
21497                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
21498                 CHECK_ACCESS(_res_conv_25_ptr);
21499                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
21500                 FREE((void*)_res_conv_25);
21501                 _res_constr.data[z] = _res_conv_25_conv;
21502         }
21503         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21504         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
21505 }
21506
21507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21508         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21509         CHECK_ACCESS(o_ptr);
21510         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
21511         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
21512         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21513         *ret_copy = COption_NetAddressZ_some(o_conv);
21514         int64_t ret_ref = (uintptr_t)ret_copy;
21515         return ret_ref;
21516 }
21517
21518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
21519         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21520         *ret_copy = COption_NetAddressZ_none();
21521         int64_t ret_ref = (uintptr_t)ret_copy;
21522         return ret_ref;
21523 }
21524
21525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21526         if ((_res & 1) != 0) return;
21527         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21528         CHECK_ACCESS(_res_ptr);
21529         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
21530         FREE((void*)_res);
21531         COption_NetAddressZ_free(_res_conv);
21532 }
21533
21534 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
21535         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21536         *ret_copy = COption_NetAddressZ_clone(arg);
21537 int64_t ret_ref = (uintptr_t)ret_copy;
21538         return ret_ref;
21539 }
21540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21541         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
21542         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
21543         return ret_conv;
21544 }
21545
21546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21547         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
21548         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
21549         *ret_copy = COption_NetAddressZ_clone(orig_conv);
21550         int64_t ret_ref = (uintptr_t)ret_copy;
21551         return ret_ref;
21552 }
21553
21554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21555         LDKCVec_u8Z o_ref;
21556         o_ref.datalen = (*env)->GetArrayLength(env, o);
21557         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
21558         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
21559         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21560         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
21561         return (int64_t)ret_conv;
21562 }
21563
21564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21565         LDKPeerHandleError e_conv;
21566         e_conv.inner = (void*)(e & (~1));
21567         e_conv.is_owned = (e & 1) || (e == 0);
21568         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21569         e_conv = PeerHandleError_clone(&e_conv);
21570         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21571         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
21572         return (int64_t)ret_conv;
21573 }
21574
21575 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21576         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
21577         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
21578         return ret_conv;
21579 }
21580
21581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21582         if ((_res & 1) != 0) return;
21583         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21584         CHECK_ACCESS(_res_ptr);
21585         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
21586         FREE((void*)_res);
21587         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
21588 }
21589
21590 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
21591         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21592         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
21593         return (int64_t)ret_conv;
21594 }
21595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21596         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
21597         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
21598         return ret_conv;
21599 }
21600
21601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21602         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
21603         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
21604         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
21605         return (int64_t)ret_conv;
21606 }
21607
21608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
21609         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21610         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
21611         return (int64_t)ret_conv;
21612 }
21613
21614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21615         LDKPeerHandleError e_conv;
21616         e_conv.inner = (void*)(e & (~1));
21617         e_conv.is_owned = (e & 1) || (e == 0);
21618         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21619         e_conv = PeerHandleError_clone(&e_conv);
21620         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21621         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
21622         return (int64_t)ret_conv;
21623 }
21624
21625 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21626         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
21627         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
21628         return ret_conv;
21629 }
21630
21631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21632         if ((_res & 1) != 0) return;
21633         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21634         CHECK_ACCESS(_res_ptr);
21635         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
21636         FREE((void*)_res);
21637         CResult_NonePeerHandleErrorZ_free(_res_conv);
21638 }
21639
21640 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
21641         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21642         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
21643         return (int64_t)ret_conv;
21644 }
21645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21646         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
21647         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
21648         return ret_conv;
21649 }
21650
21651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21652         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
21653         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
21654         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
21655         return (int64_t)ret_conv;
21656 }
21657
21658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
21659         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21660         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
21661         return (int64_t)ret_conv;
21662 }
21663
21664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21665         LDKPeerHandleError e_conv;
21666         e_conv.inner = (void*)(e & (~1));
21667         e_conv.is_owned = (e & 1) || (e == 0);
21668         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21669         e_conv = PeerHandleError_clone(&e_conv);
21670         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21671         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
21672         return (int64_t)ret_conv;
21673 }
21674
21675 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21676         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
21677         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
21678         return ret_conv;
21679 }
21680
21681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21682         if ((_res & 1) != 0) return;
21683         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21684         CHECK_ACCESS(_res_ptr);
21685         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
21686         FREE((void*)_res);
21687         CResult_boolPeerHandleErrorZ_free(_res_conv);
21688 }
21689
21690 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
21691         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21692         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
21693         return (int64_t)ret_conv;
21694 }
21695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21696         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
21697         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
21698         return ret_conv;
21699 }
21700
21701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21702         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
21703         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
21704         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
21705         return (int64_t)ret_conv;
21706 }
21707
21708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
21709         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
21710         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
21711         return (int64_t)ret_conv;
21712 }
21713
21714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21715         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
21716         CHECK_ACCESS(e_ptr);
21717         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
21718         e_conv = GraphSyncError_clone((LDKGraphSyncError*)(((uintptr_t)e) & ~1));
21719         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
21720         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
21721         return (int64_t)ret_conv;
21722 }
21723
21724 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21725         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)(o & ~1);
21726         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
21727         return ret_conv;
21728 }
21729
21730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21731         if ((_res & 1) != 0) return;
21732         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21733         CHECK_ACCESS(_res_ptr);
21734         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
21735         FREE((void*)_res);
21736         CResult_u32GraphSyncErrorZ_free(_res_conv);
21737 }
21738
21739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21740         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21741         CHECK_ACCESS(o_ptr);
21742         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
21743         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
21744         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21745         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
21746         return (int64_t)ret_conv;
21747 }
21748
21749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21750         LDKDecodeError e_conv;
21751         e_conv.inner = (void*)(e & (~1));
21752         e_conv.is_owned = (e & 1) || (e == 0);
21753         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21754         e_conv = DecodeError_clone(&e_conv);
21755         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21756         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
21757         return (int64_t)ret_conv;
21758 }
21759
21760 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21761         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
21762         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
21763         return ret_conv;
21764 }
21765
21766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21767         if ((_res & 1) != 0) return;
21768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21769         CHECK_ACCESS(_res_ptr);
21770         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
21771         FREE((void*)_res);
21772         CResult_NetAddressDecodeErrorZ_free(_res_conv);
21773 }
21774
21775 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
21776         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21777         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
21778         return (int64_t)ret_conv;
21779 }
21780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21781         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
21782         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
21783         return ret_conv;
21784 }
21785
21786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21787         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
21788         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21789         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
21790         return (int64_t)ret_conv;
21791 }
21792
21793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21794         LDKCVec_UpdateAddHTLCZ _res_constr;
21795         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21796         if (_res_constr.datalen > 0)
21797                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21798         else
21799                 _res_constr.data = NULL;
21800         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21801         for (size_t p = 0; p < _res_constr.datalen; p++) {
21802                 int64_t _res_conv_15 = _res_vals[p];
21803                 LDKUpdateAddHTLC _res_conv_15_conv;
21804                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
21805                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
21806                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
21807                 _res_constr.data[p] = _res_conv_15_conv;
21808         }
21809         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21810         CVec_UpdateAddHTLCZ_free(_res_constr);
21811 }
21812
21813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21814         LDKCVec_UpdateFulfillHTLCZ _res_constr;
21815         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21816         if (_res_constr.datalen > 0)
21817                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21818         else
21819                 _res_constr.data = NULL;
21820         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21821         for (size_t t = 0; t < _res_constr.datalen; t++) {
21822                 int64_t _res_conv_19 = _res_vals[t];
21823                 LDKUpdateFulfillHTLC _res_conv_19_conv;
21824                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
21825                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
21826                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
21827                 _res_constr.data[t] = _res_conv_19_conv;
21828         }
21829         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21830         CVec_UpdateFulfillHTLCZ_free(_res_constr);
21831 }
21832
21833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21834         LDKCVec_UpdateFailHTLCZ _res_constr;
21835         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21836         if (_res_constr.datalen > 0)
21837                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21838         else
21839                 _res_constr.data = NULL;
21840         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21841         for (size_t q = 0; q < _res_constr.datalen; q++) {
21842                 int64_t _res_conv_16 = _res_vals[q];
21843                 LDKUpdateFailHTLC _res_conv_16_conv;
21844                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
21845                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
21846                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21847                 _res_constr.data[q] = _res_conv_16_conv;
21848         }
21849         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21850         CVec_UpdateFailHTLCZ_free(_res_constr);
21851 }
21852
21853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21854         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
21855         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21856         if (_res_constr.datalen > 0)
21857                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21858         else
21859                 _res_constr.data = NULL;
21860         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21861         for (size_t z = 0; z < _res_constr.datalen; z++) {
21862                 int64_t _res_conv_25 = _res_vals[z];
21863                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
21864                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
21865                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
21866                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
21867                 _res_constr.data[z] = _res_conv_25_conv;
21868         }
21869         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21870         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
21871 }
21872
21873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21874         LDKAcceptChannel o_conv;
21875         o_conv.inner = (void*)(o & (~1));
21876         o_conv.is_owned = (o & 1) || (o == 0);
21877         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21878         o_conv = AcceptChannel_clone(&o_conv);
21879         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21880         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
21881         return (int64_t)ret_conv;
21882 }
21883
21884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21885         LDKDecodeError e_conv;
21886         e_conv.inner = (void*)(e & (~1));
21887         e_conv.is_owned = (e & 1) || (e == 0);
21888         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21889         e_conv = DecodeError_clone(&e_conv);
21890         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21891         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
21892         return (int64_t)ret_conv;
21893 }
21894
21895 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21896         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
21897         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
21898         return ret_conv;
21899 }
21900
21901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21902         if ((_res & 1) != 0) return;
21903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21904         CHECK_ACCESS(_res_ptr);
21905         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
21906         FREE((void*)_res);
21907         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
21908 }
21909
21910 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
21911         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21912         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
21913         return (int64_t)ret_conv;
21914 }
21915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21916         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
21917         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
21918         return ret_conv;
21919 }
21920
21921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21922         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
21923         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21924         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
21925         return (int64_t)ret_conv;
21926 }
21927
21928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21929         LDKAnnouncementSignatures o_conv;
21930         o_conv.inner = (void*)(o & (~1));
21931         o_conv.is_owned = (o & 1) || (o == 0);
21932         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21933         o_conv = AnnouncementSignatures_clone(&o_conv);
21934         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21935         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
21936         return (int64_t)ret_conv;
21937 }
21938
21939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21940         LDKDecodeError e_conv;
21941         e_conv.inner = (void*)(e & (~1));
21942         e_conv.is_owned = (e & 1) || (e == 0);
21943         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21944         e_conv = DecodeError_clone(&e_conv);
21945         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21946         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
21947         return (int64_t)ret_conv;
21948 }
21949
21950 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21951         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
21952         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
21953         return ret_conv;
21954 }
21955
21956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21957         if ((_res & 1) != 0) return;
21958         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21959         CHECK_ACCESS(_res_ptr);
21960         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
21961         FREE((void*)_res);
21962         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
21963 }
21964
21965 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
21966         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21967         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
21968         return (int64_t)ret_conv;
21969 }
21970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21971         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
21972         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
21973         return ret_conv;
21974 }
21975
21976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21977         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
21978         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21979         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
21980         return (int64_t)ret_conv;
21981 }
21982
21983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21984         LDKChannelReestablish o_conv;
21985         o_conv.inner = (void*)(o & (~1));
21986         o_conv.is_owned = (o & 1) || (o == 0);
21987         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21988         o_conv = ChannelReestablish_clone(&o_conv);
21989         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21990         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
21991         return (int64_t)ret_conv;
21992 }
21993
21994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21995         LDKDecodeError e_conv;
21996         e_conv.inner = (void*)(e & (~1));
21997         e_conv.is_owned = (e & 1) || (e == 0);
21998         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21999         e_conv = DecodeError_clone(&e_conv);
22000         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22001         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
22002         return (int64_t)ret_conv;
22003 }
22004
22005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22006         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
22007         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
22008         return ret_conv;
22009 }
22010
22011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22012         if ((_res & 1) != 0) return;
22013         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22014         CHECK_ACCESS(_res_ptr);
22015         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
22016         FREE((void*)_res);
22017         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
22018 }
22019
22020 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
22021         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22022         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
22023         return (int64_t)ret_conv;
22024 }
22025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22026         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
22027         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
22028         return ret_conv;
22029 }
22030
22031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22032         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
22033         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22034         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
22035         return (int64_t)ret_conv;
22036 }
22037
22038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22039         LDKClosingSigned o_conv;
22040         o_conv.inner = (void*)(o & (~1));
22041         o_conv.is_owned = (o & 1) || (o == 0);
22042         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22043         o_conv = ClosingSigned_clone(&o_conv);
22044         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22045         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
22046         return (int64_t)ret_conv;
22047 }
22048
22049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22050         LDKDecodeError e_conv;
22051         e_conv.inner = (void*)(e & (~1));
22052         e_conv.is_owned = (e & 1) || (e == 0);
22053         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22054         e_conv = DecodeError_clone(&e_conv);
22055         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22056         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
22057         return (int64_t)ret_conv;
22058 }
22059
22060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22061         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
22062         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
22063         return ret_conv;
22064 }
22065
22066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22067         if ((_res & 1) != 0) return;
22068         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22069         CHECK_ACCESS(_res_ptr);
22070         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
22071         FREE((void*)_res);
22072         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
22073 }
22074
22075 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
22076         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22077         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
22078         return (int64_t)ret_conv;
22079 }
22080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22081         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
22082         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
22083         return ret_conv;
22084 }
22085
22086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22087         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
22088         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22089         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
22090         return (int64_t)ret_conv;
22091 }
22092
22093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22094         LDKClosingSignedFeeRange o_conv;
22095         o_conv.inner = (void*)(o & (~1));
22096         o_conv.is_owned = (o & 1) || (o == 0);
22097         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22098         o_conv = ClosingSignedFeeRange_clone(&o_conv);
22099         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22100         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
22101         return (int64_t)ret_conv;
22102 }
22103
22104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22105         LDKDecodeError e_conv;
22106         e_conv.inner = (void*)(e & (~1));
22107         e_conv.is_owned = (e & 1) || (e == 0);
22108         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22109         e_conv = DecodeError_clone(&e_conv);
22110         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22111         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
22112         return (int64_t)ret_conv;
22113 }
22114
22115 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22116         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
22117         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
22118         return ret_conv;
22119 }
22120
22121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22122         if ((_res & 1) != 0) return;
22123         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22124         CHECK_ACCESS(_res_ptr);
22125         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
22126         FREE((void*)_res);
22127         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
22128 }
22129
22130 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
22131         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22132         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
22133         return (int64_t)ret_conv;
22134 }
22135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22136         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
22137         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
22138         return ret_conv;
22139 }
22140
22141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22142         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
22143         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
22144         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
22145         return (int64_t)ret_conv;
22146 }
22147
22148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22149         LDKCommitmentSigned o_conv;
22150         o_conv.inner = (void*)(o & (~1));
22151         o_conv.is_owned = (o & 1) || (o == 0);
22152         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22153         o_conv = CommitmentSigned_clone(&o_conv);
22154         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22155         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
22156         return (int64_t)ret_conv;
22157 }
22158
22159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22160         LDKDecodeError e_conv;
22161         e_conv.inner = (void*)(e & (~1));
22162         e_conv.is_owned = (e & 1) || (e == 0);
22163         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22164         e_conv = DecodeError_clone(&e_conv);
22165         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22166         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
22167         return (int64_t)ret_conv;
22168 }
22169
22170 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22171         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
22172         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
22173         return ret_conv;
22174 }
22175
22176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22177         if ((_res & 1) != 0) return;
22178         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22179         CHECK_ACCESS(_res_ptr);
22180         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
22181         FREE((void*)_res);
22182         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
22183 }
22184
22185 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
22186         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22187         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
22188         return (int64_t)ret_conv;
22189 }
22190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22191         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
22192         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
22193         return ret_conv;
22194 }
22195
22196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22197         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
22198         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
22199         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
22200         return (int64_t)ret_conv;
22201 }
22202
22203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22204         LDKFundingCreated o_conv;
22205         o_conv.inner = (void*)(o & (~1));
22206         o_conv.is_owned = (o & 1) || (o == 0);
22207         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22208         o_conv = FundingCreated_clone(&o_conv);
22209         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22210         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
22211         return (int64_t)ret_conv;
22212 }
22213
22214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22215         LDKDecodeError e_conv;
22216         e_conv.inner = (void*)(e & (~1));
22217         e_conv.is_owned = (e & 1) || (e == 0);
22218         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22219         e_conv = DecodeError_clone(&e_conv);
22220         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22221         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
22222         return (int64_t)ret_conv;
22223 }
22224
22225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22226         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
22227         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
22228         return ret_conv;
22229 }
22230
22231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22232         if ((_res & 1) != 0) return;
22233         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22234         CHECK_ACCESS(_res_ptr);
22235         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
22236         FREE((void*)_res);
22237         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
22238 }
22239
22240 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
22241         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22242         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
22243         return (int64_t)ret_conv;
22244 }
22245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22246         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
22247         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
22248         return ret_conv;
22249 }
22250
22251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22252         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
22253         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
22254         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
22255         return (int64_t)ret_conv;
22256 }
22257
22258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22259         LDKFundingSigned o_conv;
22260         o_conv.inner = (void*)(o & (~1));
22261         o_conv.is_owned = (o & 1) || (o == 0);
22262         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22263         o_conv = FundingSigned_clone(&o_conv);
22264         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22265         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
22266         return (int64_t)ret_conv;
22267 }
22268
22269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22270         LDKDecodeError e_conv;
22271         e_conv.inner = (void*)(e & (~1));
22272         e_conv.is_owned = (e & 1) || (e == 0);
22273         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22274         e_conv = DecodeError_clone(&e_conv);
22275         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22276         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
22277         return (int64_t)ret_conv;
22278 }
22279
22280 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22281         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
22282         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
22283         return ret_conv;
22284 }
22285
22286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22287         if ((_res & 1) != 0) return;
22288         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22289         CHECK_ACCESS(_res_ptr);
22290         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
22291         FREE((void*)_res);
22292         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
22293 }
22294
22295 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
22296         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22297         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
22298         return (int64_t)ret_conv;
22299 }
22300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22301         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
22302         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
22303         return ret_conv;
22304 }
22305
22306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22307         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
22308         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
22309         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
22310         return (int64_t)ret_conv;
22311 }
22312
22313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22314         LDKChannelReady o_conv;
22315         o_conv.inner = (void*)(o & (~1));
22316         o_conv.is_owned = (o & 1) || (o == 0);
22317         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22318         o_conv = ChannelReady_clone(&o_conv);
22319         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22320         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
22321         return (int64_t)ret_conv;
22322 }
22323
22324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22325         LDKDecodeError e_conv;
22326         e_conv.inner = (void*)(e & (~1));
22327         e_conv.is_owned = (e & 1) || (e == 0);
22328         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22329         e_conv = DecodeError_clone(&e_conv);
22330         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22331         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
22332         return (int64_t)ret_conv;
22333 }
22334
22335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22336         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
22337         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
22338         return ret_conv;
22339 }
22340
22341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22342         if ((_res & 1) != 0) return;
22343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22344         CHECK_ACCESS(_res_ptr);
22345         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
22346         FREE((void*)_res);
22347         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
22348 }
22349
22350 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
22351         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22352         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
22353         return (int64_t)ret_conv;
22354 }
22355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22356         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
22357         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
22358         return ret_conv;
22359 }
22360
22361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22362         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
22363         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
22364         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
22365         return (int64_t)ret_conv;
22366 }
22367
22368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22369         LDKInit o_conv;
22370         o_conv.inner = (void*)(o & (~1));
22371         o_conv.is_owned = (o & 1) || (o == 0);
22372         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22373         o_conv = Init_clone(&o_conv);
22374         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22375         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
22376         return (int64_t)ret_conv;
22377 }
22378
22379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22380         LDKDecodeError e_conv;
22381         e_conv.inner = (void*)(e & (~1));
22382         e_conv.is_owned = (e & 1) || (e == 0);
22383         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22384         e_conv = DecodeError_clone(&e_conv);
22385         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22386         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
22387         return (int64_t)ret_conv;
22388 }
22389
22390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22391         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
22392         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
22393         return ret_conv;
22394 }
22395
22396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22397         if ((_res & 1) != 0) return;
22398         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22399         CHECK_ACCESS(_res_ptr);
22400         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
22401         FREE((void*)_res);
22402         CResult_InitDecodeErrorZ_free(_res_conv);
22403 }
22404
22405 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
22406         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22407         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
22408         return (int64_t)ret_conv;
22409 }
22410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22411         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
22412         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
22413         return ret_conv;
22414 }
22415
22416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22417         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
22418         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
22419         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
22420         return (int64_t)ret_conv;
22421 }
22422
22423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22424         LDKOpenChannel o_conv;
22425         o_conv.inner = (void*)(o & (~1));
22426         o_conv.is_owned = (o & 1) || (o == 0);
22427         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22428         o_conv = OpenChannel_clone(&o_conv);
22429         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22430         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
22431         return (int64_t)ret_conv;
22432 }
22433
22434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22435         LDKDecodeError e_conv;
22436         e_conv.inner = (void*)(e & (~1));
22437         e_conv.is_owned = (e & 1) || (e == 0);
22438         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22439         e_conv = DecodeError_clone(&e_conv);
22440         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22441         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
22442         return (int64_t)ret_conv;
22443 }
22444
22445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22446         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
22447         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
22448         return ret_conv;
22449 }
22450
22451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22452         if ((_res & 1) != 0) return;
22453         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22454         CHECK_ACCESS(_res_ptr);
22455         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
22456         FREE((void*)_res);
22457         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
22458 }
22459
22460 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
22461         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22462         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
22463         return (int64_t)ret_conv;
22464 }
22465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22466         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
22467         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
22468         return ret_conv;
22469 }
22470
22471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22472         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
22473         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
22474         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
22475         return (int64_t)ret_conv;
22476 }
22477
22478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22479         LDKRevokeAndACK o_conv;
22480         o_conv.inner = (void*)(o & (~1));
22481         o_conv.is_owned = (o & 1) || (o == 0);
22482         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22483         o_conv = RevokeAndACK_clone(&o_conv);
22484         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22485         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
22486         return (int64_t)ret_conv;
22487 }
22488
22489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22490         LDKDecodeError e_conv;
22491         e_conv.inner = (void*)(e & (~1));
22492         e_conv.is_owned = (e & 1) || (e == 0);
22493         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22494         e_conv = DecodeError_clone(&e_conv);
22495         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22496         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
22497         return (int64_t)ret_conv;
22498 }
22499
22500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22501         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
22502         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
22503         return ret_conv;
22504 }
22505
22506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22507         if ((_res & 1) != 0) return;
22508         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22509         CHECK_ACCESS(_res_ptr);
22510         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
22511         FREE((void*)_res);
22512         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
22513 }
22514
22515 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
22516         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22517         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
22518         return (int64_t)ret_conv;
22519 }
22520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22521         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
22522         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
22523         return ret_conv;
22524 }
22525
22526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22527         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
22528         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
22529         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
22530         return (int64_t)ret_conv;
22531 }
22532
22533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22534         LDKShutdown o_conv;
22535         o_conv.inner = (void*)(o & (~1));
22536         o_conv.is_owned = (o & 1) || (o == 0);
22537         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22538         o_conv = Shutdown_clone(&o_conv);
22539         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22540         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
22541         return (int64_t)ret_conv;
22542 }
22543
22544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22545         LDKDecodeError e_conv;
22546         e_conv.inner = (void*)(e & (~1));
22547         e_conv.is_owned = (e & 1) || (e == 0);
22548         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22549         e_conv = DecodeError_clone(&e_conv);
22550         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22551         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
22552         return (int64_t)ret_conv;
22553 }
22554
22555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22556         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
22557         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
22558         return ret_conv;
22559 }
22560
22561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22562         if ((_res & 1) != 0) return;
22563         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22564         CHECK_ACCESS(_res_ptr);
22565         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
22566         FREE((void*)_res);
22567         CResult_ShutdownDecodeErrorZ_free(_res_conv);
22568 }
22569
22570 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
22571         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22572         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
22573         return (int64_t)ret_conv;
22574 }
22575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22576         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
22577         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
22578         return ret_conv;
22579 }
22580
22581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22582         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
22583         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
22584         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
22585         return (int64_t)ret_conv;
22586 }
22587
22588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22589         LDKUpdateFailHTLC o_conv;
22590         o_conv.inner = (void*)(o & (~1));
22591         o_conv.is_owned = (o & 1) || (o == 0);
22592         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22593         o_conv = UpdateFailHTLC_clone(&o_conv);
22594         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22595         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
22596         return (int64_t)ret_conv;
22597 }
22598
22599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22600         LDKDecodeError e_conv;
22601         e_conv.inner = (void*)(e & (~1));
22602         e_conv.is_owned = (e & 1) || (e == 0);
22603         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22604         e_conv = DecodeError_clone(&e_conv);
22605         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22606         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
22607         return (int64_t)ret_conv;
22608 }
22609
22610 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22611         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
22612         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
22613         return ret_conv;
22614 }
22615
22616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22617         if ((_res & 1) != 0) return;
22618         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22619         CHECK_ACCESS(_res_ptr);
22620         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
22621         FREE((void*)_res);
22622         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
22623 }
22624
22625 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
22626         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22627         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
22628         return (int64_t)ret_conv;
22629 }
22630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22631         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
22632         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
22633         return ret_conv;
22634 }
22635
22636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22637         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
22638         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
22639         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
22640         return (int64_t)ret_conv;
22641 }
22642
22643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22644         LDKUpdateFailMalformedHTLC o_conv;
22645         o_conv.inner = (void*)(o & (~1));
22646         o_conv.is_owned = (o & 1) || (o == 0);
22647         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22648         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
22649         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22650         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
22651         return (int64_t)ret_conv;
22652 }
22653
22654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22655         LDKDecodeError e_conv;
22656         e_conv.inner = (void*)(e & (~1));
22657         e_conv.is_owned = (e & 1) || (e == 0);
22658         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22659         e_conv = DecodeError_clone(&e_conv);
22660         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22661         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
22662         return (int64_t)ret_conv;
22663 }
22664
22665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22666         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
22667         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
22668         return ret_conv;
22669 }
22670
22671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22672         if ((_res & 1) != 0) return;
22673         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22674         CHECK_ACCESS(_res_ptr);
22675         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
22676         FREE((void*)_res);
22677         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
22678 }
22679
22680 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
22681         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22682         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
22683         return (int64_t)ret_conv;
22684 }
22685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22686         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
22687         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
22688         return ret_conv;
22689 }
22690
22691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22692         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
22693         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
22694         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
22695         return (int64_t)ret_conv;
22696 }
22697
22698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22699         LDKUpdateFee o_conv;
22700         o_conv.inner = (void*)(o & (~1));
22701         o_conv.is_owned = (o & 1) || (o == 0);
22702         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22703         o_conv = UpdateFee_clone(&o_conv);
22704         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22705         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
22706         return (int64_t)ret_conv;
22707 }
22708
22709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22710         LDKDecodeError e_conv;
22711         e_conv.inner = (void*)(e & (~1));
22712         e_conv.is_owned = (e & 1) || (e == 0);
22713         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22714         e_conv = DecodeError_clone(&e_conv);
22715         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22716         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
22717         return (int64_t)ret_conv;
22718 }
22719
22720 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22721         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
22722         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
22723         return ret_conv;
22724 }
22725
22726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22727         if ((_res & 1) != 0) return;
22728         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22729         CHECK_ACCESS(_res_ptr);
22730         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
22731         FREE((void*)_res);
22732         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
22733 }
22734
22735 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
22736         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22737         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
22738         return (int64_t)ret_conv;
22739 }
22740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22741         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
22742         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
22743         return ret_conv;
22744 }
22745
22746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22747         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
22748         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22749         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
22750         return (int64_t)ret_conv;
22751 }
22752
22753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22754         LDKUpdateFulfillHTLC o_conv;
22755         o_conv.inner = (void*)(o & (~1));
22756         o_conv.is_owned = (o & 1) || (o == 0);
22757         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22758         o_conv = UpdateFulfillHTLC_clone(&o_conv);
22759         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22760         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
22761         return (int64_t)ret_conv;
22762 }
22763
22764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22765         LDKDecodeError e_conv;
22766         e_conv.inner = (void*)(e & (~1));
22767         e_conv.is_owned = (e & 1) || (e == 0);
22768         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22769         e_conv = DecodeError_clone(&e_conv);
22770         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22771         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
22772         return (int64_t)ret_conv;
22773 }
22774
22775 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22776         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
22777         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
22778         return ret_conv;
22779 }
22780
22781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22782         if ((_res & 1) != 0) return;
22783         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22784         CHECK_ACCESS(_res_ptr);
22785         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
22786         FREE((void*)_res);
22787         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
22788 }
22789
22790 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
22791         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22792         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
22793         return (int64_t)ret_conv;
22794 }
22795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22796         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
22797         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
22798         return ret_conv;
22799 }
22800
22801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22802         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
22803         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22804         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
22805         return (int64_t)ret_conv;
22806 }
22807
22808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22809         LDKUpdateAddHTLC o_conv;
22810         o_conv.inner = (void*)(o & (~1));
22811         o_conv.is_owned = (o & 1) || (o == 0);
22812         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22813         o_conv = UpdateAddHTLC_clone(&o_conv);
22814         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22815         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
22816         return (int64_t)ret_conv;
22817 }
22818
22819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22820         LDKDecodeError e_conv;
22821         e_conv.inner = (void*)(e & (~1));
22822         e_conv.is_owned = (e & 1) || (e == 0);
22823         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22824         e_conv = DecodeError_clone(&e_conv);
22825         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22826         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
22827         return (int64_t)ret_conv;
22828 }
22829
22830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22831         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
22832         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
22833         return ret_conv;
22834 }
22835
22836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22837         if ((_res & 1) != 0) return;
22838         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22839         CHECK_ACCESS(_res_ptr);
22840         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
22841         FREE((void*)_res);
22842         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
22843 }
22844
22845 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
22846         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22847         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
22848         return (int64_t)ret_conv;
22849 }
22850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22851         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
22852         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
22853         return ret_conv;
22854 }
22855
22856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22857         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
22858         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22859         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
22860         return (int64_t)ret_conv;
22861 }
22862
22863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22864         LDKPing o_conv;
22865         o_conv.inner = (void*)(o & (~1));
22866         o_conv.is_owned = (o & 1) || (o == 0);
22867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22868         o_conv = Ping_clone(&o_conv);
22869         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22870         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
22871         return (int64_t)ret_conv;
22872 }
22873
22874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22875         LDKDecodeError e_conv;
22876         e_conv.inner = (void*)(e & (~1));
22877         e_conv.is_owned = (e & 1) || (e == 0);
22878         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22879         e_conv = DecodeError_clone(&e_conv);
22880         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22881         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
22882         return (int64_t)ret_conv;
22883 }
22884
22885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22886         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
22887         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
22888         return ret_conv;
22889 }
22890
22891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22892         if ((_res & 1) != 0) return;
22893         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22894         CHECK_ACCESS(_res_ptr);
22895         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
22896         FREE((void*)_res);
22897         CResult_PingDecodeErrorZ_free(_res_conv);
22898 }
22899
22900 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
22901         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22902         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
22903         return (int64_t)ret_conv;
22904 }
22905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22906         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
22907         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
22908         return ret_conv;
22909 }
22910
22911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22912         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
22913         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22914         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
22915         return (int64_t)ret_conv;
22916 }
22917
22918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22919         LDKPong o_conv;
22920         o_conv.inner = (void*)(o & (~1));
22921         o_conv.is_owned = (o & 1) || (o == 0);
22922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22923         o_conv = Pong_clone(&o_conv);
22924         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22925         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
22926         return (int64_t)ret_conv;
22927 }
22928
22929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22930         LDKDecodeError e_conv;
22931         e_conv.inner = (void*)(e & (~1));
22932         e_conv.is_owned = (e & 1) || (e == 0);
22933         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22934         e_conv = DecodeError_clone(&e_conv);
22935         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22936         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
22937         return (int64_t)ret_conv;
22938 }
22939
22940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22941         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
22942         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
22943         return ret_conv;
22944 }
22945
22946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22947         if ((_res & 1) != 0) return;
22948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22949         CHECK_ACCESS(_res_ptr);
22950         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
22951         FREE((void*)_res);
22952         CResult_PongDecodeErrorZ_free(_res_conv);
22953 }
22954
22955 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
22956         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22957         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
22958         return (int64_t)ret_conv;
22959 }
22960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22961         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
22962         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
22963         return ret_conv;
22964 }
22965
22966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22967         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
22968         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22969         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
22970         return (int64_t)ret_conv;
22971 }
22972
22973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22974         LDKUnsignedChannelAnnouncement o_conv;
22975         o_conv.inner = (void*)(o & (~1));
22976         o_conv.is_owned = (o & 1) || (o == 0);
22977         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22978         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
22979         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22980         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
22981         return (int64_t)ret_conv;
22982 }
22983
22984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22985         LDKDecodeError e_conv;
22986         e_conv.inner = (void*)(e & (~1));
22987         e_conv.is_owned = (e & 1) || (e == 0);
22988         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22989         e_conv = DecodeError_clone(&e_conv);
22990         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22991         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
22992         return (int64_t)ret_conv;
22993 }
22994
22995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22996         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
22997         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
22998         return ret_conv;
22999 }
23000
23001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23002         if ((_res & 1) != 0) return;
23003         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23004         CHECK_ACCESS(_res_ptr);
23005         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
23006         FREE((void*)_res);
23007         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
23008 }
23009
23010 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23011         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23012         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
23013         return (int64_t)ret_conv;
23014 }
23015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23016         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
23017         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23018         return ret_conv;
23019 }
23020
23021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23022         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
23023         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23024         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
23025         return (int64_t)ret_conv;
23026 }
23027
23028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23029         LDKChannelAnnouncement o_conv;
23030         o_conv.inner = (void*)(o & (~1));
23031         o_conv.is_owned = (o & 1) || (o == 0);
23032         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23033         o_conv = ChannelAnnouncement_clone(&o_conv);
23034         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23035         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
23036         return (int64_t)ret_conv;
23037 }
23038
23039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23040         LDKDecodeError e_conv;
23041         e_conv.inner = (void*)(e & (~1));
23042         e_conv.is_owned = (e & 1) || (e == 0);
23043         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23044         e_conv = DecodeError_clone(&e_conv);
23045         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23046         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
23047         return (int64_t)ret_conv;
23048 }
23049
23050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23051         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
23052         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
23053         return ret_conv;
23054 }
23055
23056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23057         if ((_res & 1) != 0) return;
23058         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23059         CHECK_ACCESS(_res_ptr);
23060         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
23061         FREE((void*)_res);
23062         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
23063 }
23064
23065 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23066         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23067         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
23068         return (int64_t)ret_conv;
23069 }
23070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23071         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
23072         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23073         return ret_conv;
23074 }
23075
23076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23077         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
23078         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
23079         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
23080         return (int64_t)ret_conv;
23081 }
23082
23083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23084         LDKUnsignedChannelUpdate o_conv;
23085         o_conv.inner = (void*)(o & (~1));
23086         o_conv.is_owned = (o & 1) || (o == 0);
23087         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23088         o_conv = UnsignedChannelUpdate_clone(&o_conv);
23089         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23090         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
23091         return (int64_t)ret_conv;
23092 }
23093
23094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23095         LDKDecodeError e_conv;
23096         e_conv.inner = (void*)(e & (~1));
23097         e_conv.is_owned = (e & 1) || (e == 0);
23098         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23099         e_conv = DecodeError_clone(&e_conv);
23100         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23101         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
23102         return (int64_t)ret_conv;
23103 }
23104
23105 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23106         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
23107         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
23108         return ret_conv;
23109 }
23110
23111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23112         if ((_res & 1) != 0) return;
23113         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23114         CHECK_ACCESS(_res_ptr);
23115         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
23116         FREE((void*)_res);
23117         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
23118 }
23119
23120 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
23121         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23122         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
23123         return (int64_t)ret_conv;
23124 }
23125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23126         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
23127         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
23128         return ret_conv;
23129 }
23130
23131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23132         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
23133         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
23134         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
23135         return (int64_t)ret_conv;
23136 }
23137
23138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23139         LDKChannelUpdate o_conv;
23140         o_conv.inner = (void*)(o & (~1));
23141         o_conv.is_owned = (o & 1) || (o == 0);
23142         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23143         o_conv = ChannelUpdate_clone(&o_conv);
23144         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23145         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
23146         return (int64_t)ret_conv;
23147 }
23148
23149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23150         LDKDecodeError e_conv;
23151         e_conv.inner = (void*)(e & (~1));
23152         e_conv.is_owned = (e & 1) || (e == 0);
23153         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23154         e_conv = DecodeError_clone(&e_conv);
23155         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23156         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
23157         return (int64_t)ret_conv;
23158 }
23159
23160 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23161         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
23162         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
23163         return ret_conv;
23164 }
23165
23166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23167         if ((_res & 1) != 0) return;
23168         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23169         CHECK_ACCESS(_res_ptr);
23170         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
23171         FREE((void*)_res);
23172         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
23173 }
23174
23175 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
23176         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23177         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
23178         return (int64_t)ret_conv;
23179 }
23180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23181         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
23182         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
23183         return ret_conv;
23184 }
23185
23186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23187         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
23188         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
23189         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
23190         return (int64_t)ret_conv;
23191 }
23192
23193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23194         LDKErrorMessage o_conv;
23195         o_conv.inner = (void*)(o & (~1));
23196         o_conv.is_owned = (o & 1) || (o == 0);
23197         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23198         o_conv = ErrorMessage_clone(&o_conv);
23199         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23200         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
23201         return (int64_t)ret_conv;
23202 }
23203
23204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23205         LDKDecodeError e_conv;
23206         e_conv.inner = (void*)(e & (~1));
23207         e_conv.is_owned = (e & 1) || (e == 0);
23208         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23209         e_conv = DecodeError_clone(&e_conv);
23210         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23211         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
23212         return (int64_t)ret_conv;
23213 }
23214
23215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23216         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
23217         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
23218         return ret_conv;
23219 }
23220
23221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23222         if ((_res & 1) != 0) return;
23223         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23224         CHECK_ACCESS(_res_ptr);
23225         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
23226         FREE((void*)_res);
23227         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
23228 }
23229
23230 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
23231         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23232         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
23233         return (int64_t)ret_conv;
23234 }
23235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23236         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
23237         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
23238         return ret_conv;
23239 }
23240
23241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23242         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
23243         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
23244         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
23245         return (int64_t)ret_conv;
23246 }
23247
23248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23249         LDKWarningMessage o_conv;
23250         o_conv.inner = (void*)(o & (~1));
23251         o_conv.is_owned = (o & 1) || (o == 0);
23252         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23253         o_conv = WarningMessage_clone(&o_conv);
23254         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23255         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
23256         return (int64_t)ret_conv;
23257 }
23258
23259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23260         LDKDecodeError e_conv;
23261         e_conv.inner = (void*)(e & (~1));
23262         e_conv.is_owned = (e & 1) || (e == 0);
23263         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23264         e_conv = DecodeError_clone(&e_conv);
23265         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23266         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
23267         return (int64_t)ret_conv;
23268 }
23269
23270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23271         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
23272         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
23273         return ret_conv;
23274 }
23275
23276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23277         if ((_res & 1) != 0) return;
23278         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23279         CHECK_ACCESS(_res_ptr);
23280         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
23281         FREE((void*)_res);
23282         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
23283 }
23284
23285 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
23286         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23287         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
23288         return (int64_t)ret_conv;
23289 }
23290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23291         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
23292         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
23293         return ret_conv;
23294 }
23295
23296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23297         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
23298         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
23299         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
23300         return (int64_t)ret_conv;
23301 }
23302
23303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23304         LDKUnsignedNodeAnnouncement o_conv;
23305         o_conv.inner = (void*)(o & (~1));
23306         o_conv.is_owned = (o & 1) || (o == 0);
23307         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23308         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
23309         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23310         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
23311         return (int64_t)ret_conv;
23312 }
23313
23314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23315         LDKDecodeError e_conv;
23316         e_conv.inner = (void*)(e & (~1));
23317         e_conv.is_owned = (e & 1) || (e == 0);
23318         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23319         e_conv = DecodeError_clone(&e_conv);
23320         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23321         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
23322         return (int64_t)ret_conv;
23323 }
23324
23325 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23326         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
23327         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23328         return ret_conv;
23329 }
23330
23331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23332         if ((_res & 1) != 0) return;
23333         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23334         CHECK_ACCESS(_res_ptr);
23335         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
23336         FREE((void*)_res);
23337         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
23338 }
23339
23340 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23341         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23342         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
23343         return (int64_t)ret_conv;
23344 }
23345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23346         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
23347         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23348         return ret_conv;
23349 }
23350
23351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23352         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
23353         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
23354         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
23355         return (int64_t)ret_conv;
23356 }
23357
23358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23359         LDKNodeAnnouncement o_conv;
23360         o_conv.inner = (void*)(o & (~1));
23361         o_conv.is_owned = (o & 1) || (o == 0);
23362         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23363         o_conv = NodeAnnouncement_clone(&o_conv);
23364         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23365         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
23366         return (int64_t)ret_conv;
23367 }
23368
23369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23370         LDKDecodeError e_conv;
23371         e_conv.inner = (void*)(e & (~1));
23372         e_conv.is_owned = (e & 1) || (e == 0);
23373         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23374         e_conv = DecodeError_clone(&e_conv);
23375         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23376         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
23377         return (int64_t)ret_conv;
23378 }
23379
23380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23381         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
23382         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
23383         return ret_conv;
23384 }
23385
23386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23387         if ((_res & 1) != 0) return;
23388         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23389         CHECK_ACCESS(_res_ptr);
23390         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
23391         FREE((void*)_res);
23392         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
23393 }
23394
23395 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23396         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23397         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
23398         return (int64_t)ret_conv;
23399 }
23400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23401         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
23402         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23403         return ret_conv;
23404 }
23405
23406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23407         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
23408         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
23409         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
23410         return (int64_t)ret_conv;
23411 }
23412
23413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23414         LDKQueryShortChannelIds o_conv;
23415         o_conv.inner = (void*)(o & (~1));
23416         o_conv.is_owned = (o & 1) || (o == 0);
23417         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23418         o_conv = QueryShortChannelIds_clone(&o_conv);
23419         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23420         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
23421         return (int64_t)ret_conv;
23422 }
23423
23424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23425         LDKDecodeError e_conv;
23426         e_conv.inner = (void*)(e & (~1));
23427         e_conv.is_owned = (e & 1) || (e == 0);
23428         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23429         e_conv = DecodeError_clone(&e_conv);
23430         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23431         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
23432         return (int64_t)ret_conv;
23433 }
23434
23435 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23436         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
23437         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
23438         return ret_conv;
23439 }
23440
23441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23442         if ((_res & 1) != 0) return;
23443         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23444         CHECK_ACCESS(_res_ptr);
23445         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
23446         FREE((void*)_res);
23447         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
23448 }
23449
23450 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
23451         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23452         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
23453         return (int64_t)ret_conv;
23454 }
23455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23456         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
23457         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
23458         return ret_conv;
23459 }
23460
23461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23462         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
23463         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
23464         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
23465         return (int64_t)ret_conv;
23466 }
23467
23468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23469         LDKReplyShortChannelIdsEnd o_conv;
23470         o_conv.inner = (void*)(o & (~1));
23471         o_conv.is_owned = (o & 1) || (o == 0);
23472         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23473         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
23474         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23475         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
23476         return (int64_t)ret_conv;
23477 }
23478
23479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23480         LDKDecodeError e_conv;
23481         e_conv.inner = (void*)(e & (~1));
23482         e_conv.is_owned = (e & 1) || (e == 0);
23483         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23484         e_conv = DecodeError_clone(&e_conv);
23485         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23486         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
23487         return (int64_t)ret_conv;
23488 }
23489
23490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23491         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
23492         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
23493         return ret_conv;
23494 }
23495
23496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23497         if ((_res & 1) != 0) return;
23498         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23499         CHECK_ACCESS(_res_ptr);
23500         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
23501         FREE((void*)_res);
23502         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
23503 }
23504
23505 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
23506         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23507         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
23508         return (int64_t)ret_conv;
23509 }
23510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23511         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
23512         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
23513         return ret_conv;
23514 }
23515
23516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23517         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
23518         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
23519         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
23520         return (int64_t)ret_conv;
23521 }
23522
23523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23524         LDKQueryChannelRange o_conv;
23525         o_conv.inner = (void*)(o & (~1));
23526         o_conv.is_owned = (o & 1) || (o == 0);
23527         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23528         o_conv = QueryChannelRange_clone(&o_conv);
23529         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23530         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
23531         return (int64_t)ret_conv;
23532 }
23533
23534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23535         LDKDecodeError e_conv;
23536         e_conv.inner = (void*)(e & (~1));
23537         e_conv.is_owned = (e & 1) || (e == 0);
23538         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23539         e_conv = DecodeError_clone(&e_conv);
23540         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23541         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
23542         return (int64_t)ret_conv;
23543 }
23544
23545 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23546         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
23547         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
23548         return ret_conv;
23549 }
23550
23551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23552         if ((_res & 1) != 0) return;
23553         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23554         CHECK_ACCESS(_res_ptr);
23555         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
23556         FREE((void*)_res);
23557         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
23558 }
23559
23560 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
23561         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23562         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
23563         return (int64_t)ret_conv;
23564 }
23565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23566         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
23567         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
23568         return ret_conv;
23569 }
23570
23571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23572         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
23573         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
23574         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
23575         return (int64_t)ret_conv;
23576 }
23577
23578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23579         LDKReplyChannelRange o_conv;
23580         o_conv.inner = (void*)(o & (~1));
23581         o_conv.is_owned = (o & 1) || (o == 0);
23582         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23583         o_conv = ReplyChannelRange_clone(&o_conv);
23584         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23585         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
23586         return (int64_t)ret_conv;
23587 }
23588
23589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23590         LDKDecodeError e_conv;
23591         e_conv.inner = (void*)(e & (~1));
23592         e_conv.is_owned = (e & 1) || (e == 0);
23593         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23594         e_conv = DecodeError_clone(&e_conv);
23595         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23596         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
23597         return (int64_t)ret_conv;
23598 }
23599
23600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23601         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
23602         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
23603         return ret_conv;
23604 }
23605
23606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23607         if ((_res & 1) != 0) return;
23608         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23609         CHECK_ACCESS(_res_ptr);
23610         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
23611         FREE((void*)_res);
23612         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
23613 }
23614
23615 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
23616         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23617         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
23618         return (int64_t)ret_conv;
23619 }
23620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23621         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
23622         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
23623         return ret_conv;
23624 }
23625
23626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23627         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
23628         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
23629         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
23630         return (int64_t)ret_conv;
23631 }
23632
23633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23634         LDKGossipTimestampFilter o_conv;
23635         o_conv.inner = (void*)(o & (~1));
23636         o_conv.is_owned = (o & 1) || (o == 0);
23637         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23638         o_conv = GossipTimestampFilter_clone(&o_conv);
23639         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23640         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
23641         return (int64_t)ret_conv;
23642 }
23643
23644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23645         LDKDecodeError e_conv;
23646         e_conv.inner = (void*)(e & (~1));
23647         e_conv.is_owned = (e & 1) || (e == 0);
23648         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23649         e_conv = DecodeError_clone(&e_conv);
23650         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23651         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
23652         return (int64_t)ret_conv;
23653 }
23654
23655 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23656         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
23657         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
23658         return ret_conv;
23659 }
23660
23661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23662         if ((_res & 1) != 0) return;
23663         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23664         CHECK_ACCESS(_res_ptr);
23665         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
23666         FREE((void*)_res);
23667         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
23668 }
23669
23670 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
23671         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23672         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
23673         return (int64_t)ret_conv;
23674 }
23675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23676         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
23677         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
23678         return ret_conv;
23679 }
23680
23681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23682         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
23683         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
23684         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
23685         return (int64_t)ret_conv;
23686 }
23687
23688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23689         LDKCVec_PhantomRouteHintsZ _res_constr;
23690         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23691         if (_res_constr.datalen > 0)
23692                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
23693         else
23694                 _res_constr.data = NULL;
23695         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23696         for (size_t t = 0; t < _res_constr.datalen; t++) {
23697                 int64_t _res_conv_19 = _res_vals[t];
23698                 LDKPhantomRouteHints _res_conv_19_conv;
23699                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
23700                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
23701                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
23702                 _res_constr.data[t] = _res_conv_19_conv;
23703         }
23704         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23705         CVec_PhantomRouteHintsZ_free(_res_constr);
23706 }
23707
23708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23709         LDKInvoice o_conv;
23710         o_conv.inner = (void*)(o & (~1));
23711         o_conv.is_owned = (o & 1) || (o == 0);
23712         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23713         o_conv = Invoice_clone(&o_conv);
23714         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23715         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
23716         return (int64_t)ret_conv;
23717 }
23718
23719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23720         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
23721         CHECK_ACCESS(e_ptr);
23722         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
23723         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
23724         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23725         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
23726         return (int64_t)ret_conv;
23727 }
23728
23729 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23730         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
23731         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
23732         return ret_conv;
23733 }
23734
23735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23736         if ((_res & 1) != 0) return;
23737         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23738         CHECK_ACCESS(_res_ptr);
23739         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
23740         FREE((void*)_res);
23741         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
23742 }
23743
23744 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
23745         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23746         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
23747         return (int64_t)ret_conv;
23748 }
23749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23750         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
23751         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
23752         return ret_conv;
23753 }
23754
23755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23756         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
23757         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23758         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
23759         return (int64_t)ret_conv;
23760 }
23761
23762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23763         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
23764         CHECK_ACCESS(o_ptr);
23765         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
23766         if (o_conv.free == LDKFilter_JCalls_free) {
23767                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23768                 LDKFilter_JCalls_cloned(&o_conv);
23769         }
23770         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
23771         *ret_copy = COption_FilterZ_some(o_conv);
23772         int64_t ret_ref = (uintptr_t)ret_copy;
23773         return ret_ref;
23774 }
23775
23776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
23777         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
23778         *ret_copy = COption_FilterZ_none();
23779         int64_t ret_ref = (uintptr_t)ret_copy;
23780         return ret_ref;
23781 }
23782
23783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23784         if ((_res & 1) != 0) return;
23785         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23786         CHECK_ACCESS(_res_ptr);
23787         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
23788         FREE((void*)_res);
23789         COption_FilterZ_free(_res_conv);
23790 }
23791
23792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23793         LDKLockedChannelMonitor o_conv;
23794         o_conv.inner = (void*)(o & (~1));
23795         o_conv.is_owned = (o & 1) || (o == 0);
23796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23797         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
23798         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23799         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
23800         return (int64_t)ret_conv;
23801 }
23802
23803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
23804         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23805         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
23806         return (int64_t)ret_conv;
23807 }
23808
23809 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23810         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
23811         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
23812         return ret_conv;
23813 }
23814
23815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23816         if ((_res & 1) != 0) return;
23817         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23818         CHECK_ACCESS(_res_ptr);
23819         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
23820         FREE((void*)_res);
23821         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
23822 }
23823
23824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23825         LDKCVec_OutPointZ _res_constr;
23826         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23827         if (_res_constr.datalen > 0)
23828                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
23829         else
23830                 _res_constr.data = NULL;
23831         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23832         for (size_t k = 0; k < _res_constr.datalen; k++) {
23833                 int64_t _res_conv_10 = _res_vals[k];
23834                 LDKOutPoint _res_conv_10_conv;
23835                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
23836                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
23837                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
23838                 _res_constr.data[k] = _res_conv_10_conv;
23839         }
23840         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23841         CVec_OutPointZ_free(_res_constr);
23842 }
23843
23844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23845         if ((this_ptr & 1) != 0) return;
23846         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23847         CHECK_ACCESS(this_ptr_ptr);
23848         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
23849         FREE((void*)this_ptr);
23850         PaymentPurpose_free(this_ptr_conv);
23851 }
23852
23853 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
23854         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23855         *ret_copy = PaymentPurpose_clone(arg);
23856 int64_t ret_ref = (uintptr_t)ret_copy;
23857         return ret_ref;
23858 }
23859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23860         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
23861         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
23862         return ret_conv;
23863 }
23864
23865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23866         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
23867         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23868         *ret_copy = PaymentPurpose_clone(orig_conv);
23869         int64_t ret_ref = (uintptr_t)ret_copy;
23870         return ret_ref;
23871 }
23872
23873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
23874         LDKThirtyTwoBytes payment_preimage_ref;
23875         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23876         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23877         LDKThirtyTwoBytes payment_secret_ref;
23878         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
23879         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
23880         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23881         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
23882         int64_t ret_ref = (uintptr_t)ret_copy;
23883         return ret_ref;
23884 }
23885
23886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
23887         LDKThirtyTwoBytes a_ref;
23888         CHECK((*env)->GetArrayLength(env, a) == 32);
23889         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23890         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23891         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
23892         int64_t ret_ref = (uintptr_t)ret_copy;
23893         return ret_ref;
23894 }
23895
23896 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
23897         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
23898         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
23899         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23900         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23901         CVec_u8Z_free(ret_var);
23902         return ret_arr;
23903 }
23904
23905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23906         LDKu8slice ser_ref;
23907         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23908         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23909         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
23910         *ret_conv = PaymentPurpose_read(ser_ref);
23911         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23912         return (int64_t)ret_conv;
23913 }
23914
23915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23916         if ((this_ptr & 1) != 0) return;
23917         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23918         CHECK_ACCESS(this_ptr_ptr);
23919         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
23920         FREE((void*)this_ptr);
23921         ClosureReason_free(this_ptr_conv);
23922 }
23923
23924 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
23925         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23926         *ret_copy = ClosureReason_clone(arg);
23927 int64_t ret_ref = (uintptr_t)ret_copy;
23928         return ret_ref;
23929 }
23930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23931         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
23932         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
23933         return ret_conv;
23934 }
23935
23936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23937         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
23938         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23939         *ret_copy = ClosureReason_clone(orig_conv);
23940         int64_t ret_ref = (uintptr_t)ret_copy;
23941         return ret_ref;
23942 }
23943
23944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
23945         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
23946         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23947         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
23948         int64_t ret_ref = (uintptr_t)ret_copy;
23949         return ret_ref;
23950 }
23951
23952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
23953         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23954         *ret_copy = ClosureReason_holder_force_closed();
23955         int64_t ret_ref = (uintptr_t)ret_copy;
23956         return ret_ref;
23957 }
23958
23959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
23960         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23961         *ret_copy = ClosureReason_cooperative_closure();
23962         int64_t ret_ref = (uintptr_t)ret_copy;
23963         return ret_ref;
23964 }
23965
23966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
23967         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23968         *ret_copy = ClosureReason_commitment_tx_confirmed();
23969         int64_t ret_ref = (uintptr_t)ret_copy;
23970         return ret_ref;
23971 }
23972
23973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
23974         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23975         *ret_copy = ClosureReason_funding_timed_out();
23976         int64_t ret_ref = (uintptr_t)ret_copy;
23977         return ret_ref;
23978 }
23979
23980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
23981         LDKStr err_conv = java_to_owned_str(env, err);
23982         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23983         *ret_copy = ClosureReason_processing_error(err_conv);
23984         int64_t ret_ref = (uintptr_t)ret_copy;
23985         return ret_ref;
23986 }
23987
23988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
23989         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23990         *ret_copy = ClosureReason_disconnected_peer();
23991         int64_t ret_ref = (uintptr_t)ret_copy;
23992         return ret_ref;
23993 }
23994
23995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
23996         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23997         *ret_copy = ClosureReason_outdated_channel_manager();
23998         int64_t ret_ref = (uintptr_t)ret_copy;
23999         return ret_ref;
24000 }
24001
24002 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
24003         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
24004         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
24005         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24006         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24007         CVec_u8Z_free(ret_var);
24008         return ret_arr;
24009 }
24010
24011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24012         LDKu8slice ser_ref;
24013         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24014         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24015         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
24016         *ret_conv = ClosureReason_read(ser_ref);
24017         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24018         return (int64_t)ret_conv;
24019 }
24020
24021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24022         if ((this_ptr & 1) != 0) return;
24023         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24024         CHECK_ACCESS(this_ptr_ptr);
24025         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
24026         FREE((void*)this_ptr);
24027         Event_free(this_ptr_conv);
24028 }
24029
24030 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
24031         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24032         *ret_copy = Event_clone(arg);
24033 int64_t ret_ref = (uintptr_t)ret_copy;
24034         return ret_ref;
24035 }
24036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24037         LDKEvent* arg_conv = (LDKEvent*)arg;
24038         int64_t ret_conv = Event_clone_ptr(arg_conv);
24039         return ret_conv;
24040 }
24041
24042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24043         LDKEvent* orig_conv = (LDKEvent*)orig;
24044         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24045         *ret_copy = Event_clone(orig_conv);
24046         int64_t ret_ref = (uintptr_t)ret_copy;
24047         return ret_ref;
24048 }
24049
24050 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) {
24051         LDKThirtyTwoBytes temporary_channel_id_ref;
24052         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24053         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
24054         LDKPublicKey counterparty_node_id_ref;
24055         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
24056         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
24057         LDKCVec_u8Z output_script_ref;
24058         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
24059         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
24060         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
24061         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24062         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
24063         int64_t ret_ref = (uintptr_t)ret_copy;
24064         return ret_ref;
24065 }
24066
24067 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) {
24068         LDKThirtyTwoBytes payment_hash_ref;
24069         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24070         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24071         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
24072         CHECK_ACCESS(purpose_ptr);
24073         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
24074         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
24075         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24076         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
24077         int64_t ret_ref = (uintptr_t)ret_copy;
24078         return ret_ref;
24079 }
24080
24081 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) {
24082         LDKThirtyTwoBytes payment_hash_ref;
24083         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24084         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24085         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
24086         CHECK_ACCESS(purpose_ptr);
24087         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
24088         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
24089         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24090         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
24091         int64_t ret_ref = (uintptr_t)ret_copy;
24092         return ret_ref;
24093 }
24094
24095 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) {
24096         LDKThirtyTwoBytes payment_id_ref;
24097         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24098         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24099         LDKThirtyTwoBytes payment_preimage_ref;
24100         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24101         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24102         LDKThirtyTwoBytes payment_hash_ref;
24103         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24104         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24105         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
24106         CHECK_ACCESS(fee_paid_msat_ptr);
24107         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
24108         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
24109         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24110         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
24111         int64_t ret_ref = (uintptr_t)ret_copy;
24112         return ret_ref;
24113 }
24114
24115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
24116         LDKThirtyTwoBytes payment_id_ref;
24117         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24118         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24119         LDKThirtyTwoBytes payment_hash_ref;
24120         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24121         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24122         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24123         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
24124         int64_t ret_ref = (uintptr_t)ret_copy;
24125         return ret_ref;
24126 }
24127
24128 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) {
24129         LDKThirtyTwoBytes payment_id_ref;
24130         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24131         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24132         LDKThirtyTwoBytes payment_hash_ref;
24133         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24134         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24135         LDKCVec_RouteHopZ path_constr;
24136         path_constr.datalen = (*env)->GetArrayLength(env, path);
24137         if (path_constr.datalen > 0)
24138                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24139         else
24140                 path_constr.data = NULL;
24141         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24142         for (size_t k = 0; k < path_constr.datalen; k++) {
24143                 int64_t path_conv_10 = path_vals[k];
24144                 LDKRouteHop path_conv_10_conv;
24145                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24146                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24147                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24148                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24149                 path_constr.data[k] = path_conv_10_conv;
24150         }
24151         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24152         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24153         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
24154         int64_t ret_ref = (uintptr_t)ret_copy;
24155         return ret_ref;
24156 }
24157
24158 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) {
24159         LDKThirtyTwoBytes payment_id_ref;
24160         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24161         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24162         LDKThirtyTwoBytes payment_hash_ref;
24163         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24164         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24165         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
24166         CHECK_ACCESS(network_update_ptr);
24167         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
24168         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
24169         LDKCVec_RouteHopZ path_constr;
24170         path_constr.datalen = (*env)->GetArrayLength(env, path);
24171         if (path_constr.datalen > 0)
24172                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
24173         else
24174                 path_constr.data = NULL;
24175         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
24176         for (size_t k = 0; k < path_constr.datalen; k++) {
24177                 int64_t path_conv_10 = path_vals[k];
24178                 LDKRouteHop path_conv_10_conv;
24179                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
24180                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
24181                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
24182                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
24183                 path_constr.data[k] = path_conv_10_conv;
24184         }
24185         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
24186         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
24187         CHECK_ACCESS(short_channel_id_ptr);
24188         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
24189         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
24190         LDKRouteParameters retry_conv;
24191         retry_conv.inner = (void*)(retry & (~1));
24192         retry_conv.is_owned = (retry & 1) || (retry == 0);
24193         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
24194         retry_conv = RouteParameters_clone(&retry_conv);
24195         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24196         *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);
24197         int64_t ret_ref = (uintptr_t)ret_copy;
24198         return ret_ref;
24199 }
24200
24201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
24202         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24203         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
24204         int64_t ret_ref = (uintptr_t)ret_copy;
24205         return ret_ref;
24206 }
24207
24208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
24209         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
24210         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
24211         if (outputs_constr.datalen > 0)
24212                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24213         else
24214                 outputs_constr.data = NULL;
24215         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
24216         for (size_t b = 0; b < outputs_constr.datalen; b++) {
24217                 int64_t outputs_conv_27 = outputs_vals[b];
24218                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
24219                 CHECK_ACCESS(outputs_conv_27_ptr);
24220                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
24221                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
24222                 outputs_constr.data[b] = outputs_conv_27_conv;
24223         }
24224         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
24225         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24226         *ret_copy = Event_spendable_outputs(outputs_constr);
24227         int64_t ret_ref = (uintptr_t)ret_copy;
24228         return ret_ref;
24229 }
24230
24231 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) {
24232         LDKThirtyTwoBytes prev_channel_id_ref;
24233         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
24234         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
24235         LDKThirtyTwoBytes next_channel_id_ref;
24236         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
24237         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
24238         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
24239         CHECK_ACCESS(fee_earned_msat_ptr);
24240         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
24241         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
24242         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24243         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
24244         int64_t ret_ref = (uintptr_t)ret_copy;
24245         return ret_ref;
24246 }
24247
24248 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) {
24249         LDKThirtyTwoBytes channel_id_ref;
24250         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24251         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24252         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
24253         CHECK_ACCESS(reason_ptr);
24254         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
24255         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
24256         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24257         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
24258         int64_t ret_ref = (uintptr_t)ret_copy;
24259         return ret_ref;
24260 }
24261
24262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
24263         LDKThirtyTwoBytes channel_id_ref;
24264         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24265         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
24266         LDKTransaction transaction_ref;
24267         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
24268         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
24269         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
24270         transaction_ref.data_is_owned = true;
24271         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24272         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
24273         int64_t ret_ref = (uintptr_t)ret_copy;
24274         return ret_ref;
24275 }
24276
24277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_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) {
24278         LDKThirtyTwoBytes temporary_channel_id_ref;
24279         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24280         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
24281         LDKPublicKey counterparty_node_id_ref;
24282         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
24283         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
24284         LDKChannelTypeFeatures channel_type_conv;
24285         channel_type_conv.inner = (void*)(channel_type & (~1));
24286         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
24287         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
24288         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
24289         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
24290         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
24291         int64_t ret_ref = (uintptr_t)ret_copy;
24292         return ret_ref;
24293 }
24294
24295 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
24296         LDKEvent* obj_conv = (LDKEvent*)obj;
24297         LDKCVec_u8Z ret_var = Event_write(obj_conv);
24298         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24299         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24300         CVec_u8Z_free(ret_var);
24301         return ret_arr;
24302 }
24303
24304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24305         LDKu8slice ser_ref;
24306         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24307         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24308         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
24309         *ret_conv = Event_read(ser_ref);
24310         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24311         return (int64_t)ret_conv;
24312 }
24313
24314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24315         if ((this_ptr & 1) != 0) return;
24316         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24317         CHECK_ACCESS(this_ptr_ptr);
24318         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
24319         FREE((void*)this_ptr);
24320         MessageSendEvent_free(this_ptr_conv);
24321 }
24322
24323 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
24324         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24325         *ret_copy = MessageSendEvent_clone(arg);
24326 int64_t ret_ref = (uintptr_t)ret_copy;
24327         return ret_ref;
24328 }
24329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24330         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
24331         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
24332         return ret_conv;
24333 }
24334
24335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24336         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
24337         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24338         *ret_copy = MessageSendEvent_clone(orig_conv);
24339         int64_t ret_ref = (uintptr_t)ret_copy;
24340         return ret_ref;
24341 }
24342
24343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24344         LDKPublicKey node_id_ref;
24345         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24346         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24347         LDKAcceptChannel msg_conv;
24348         msg_conv.inner = (void*)(msg & (~1));
24349         msg_conv.is_owned = (msg & 1) || (msg == 0);
24350         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24351         msg_conv = AcceptChannel_clone(&msg_conv);
24352         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24353         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
24354         int64_t ret_ref = (uintptr_t)ret_copy;
24355         return ret_ref;
24356 }
24357
24358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24359         LDKPublicKey node_id_ref;
24360         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24361         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24362         LDKOpenChannel msg_conv;
24363         msg_conv.inner = (void*)(msg & (~1));
24364         msg_conv.is_owned = (msg & 1) || (msg == 0);
24365         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24366         msg_conv = OpenChannel_clone(&msg_conv);
24367         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24368         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
24369         int64_t ret_ref = (uintptr_t)ret_copy;
24370         return ret_ref;
24371 }
24372
24373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24374         LDKPublicKey node_id_ref;
24375         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24376         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24377         LDKFundingCreated msg_conv;
24378         msg_conv.inner = (void*)(msg & (~1));
24379         msg_conv.is_owned = (msg & 1) || (msg == 0);
24380         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24381         msg_conv = FundingCreated_clone(&msg_conv);
24382         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24383         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
24384         int64_t ret_ref = (uintptr_t)ret_copy;
24385         return ret_ref;
24386 }
24387
24388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24389         LDKPublicKey node_id_ref;
24390         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24391         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24392         LDKFundingSigned msg_conv;
24393         msg_conv.inner = (void*)(msg & (~1));
24394         msg_conv.is_owned = (msg & 1) || (msg == 0);
24395         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24396         msg_conv = FundingSigned_clone(&msg_conv);
24397         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24398         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
24399         int64_t ret_ref = (uintptr_t)ret_copy;
24400         return ret_ref;
24401 }
24402
24403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24404         LDKPublicKey node_id_ref;
24405         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24406         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24407         LDKChannelReady msg_conv;
24408         msg_conv.inner = (void*)(msg & (~1));
24409         msg_conv.is_owned = (msg & 1) || (msg == 0);
24410         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24411         msg_conv = ChannelReady_clone(&msg_conv);
24412         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24413         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
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_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24419         LDKPublicKey node_id_ref;
24420         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24421         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24422         LDKAnnouncementSignatures msg_conv;
24423         msg_conv.inner = (void*)(msg & (~1));
24424         msg_conv.is_owned = (msg & 1) || (msg == 0);
24425         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24426         msg_conv = AnnouncementSignatures_clone(&msg_conv);
24427         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24428         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
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_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
24434         LDKPublicKey node_id_ref;
24435         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24436         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24437         LDKCommitmentUpdate updates_conv;
24438         updates_conv.inner = (void*)(updates & (~1));
24439         updates_conv.is_owned = (updates & 1) || (updates == 0);
24440         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
24441         updates_conv = CommitmentUpdate_clone(&updates_conv);
24442         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24443         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
24444         int64_t ret_ref = (uintptr_t)ret_copy;
24445         return ret_ref;
24446 }
24447
24448 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) {
24449         LDKPublicKey node_id_ref;
24450         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24451         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24452         LDKRevokeAndACK msg_conv;
24453         msg_conv.inner = (void*)(msg & (~1));
24454         msg_conv.is_owned = (msg & 1) || (msg == 0);
24455         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24456         msg_conv = RevokeAndACK_clone(&msg_conv);
24457         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24458         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
24459         int64_t ret_ref = (uintptr_t)ret_copy;
24460         return ret_ref;
24461 }
24462
24463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24464         LDKPublicKey node_id_ref;
24465         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24466         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24467         LDKClosingSigned msg_conv;
24468         msg_conv.inner = (void*)(msg & (~1));
24469         msg_conv.is_owned = (msg & 1) || (msg == 0);
24470         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24471         msg_conv = ClosingSigned_clone(&msg_conv);
24472         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24473         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
24474         int64_t ret_ref = (uintptr_t)ret_copy;
24475         return ret_ref;
24476 }
24477
24478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24479         LDKPublicKey node_id_ref;
24480         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24481         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24482         LDKShutdown msg_conv;
24483         msg_conv.inner = (void*)(msg & (~1));
24484         msg_conv.is_owned = (msg & 1) || (msg == 0);
24485         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24486         msg_conv = Shutdown_clone(&msg_conv);
24487         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24488         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
24489         int64_t ret_ref = (uintptr_t)ret_copy;
24490         return ret_ref;
24491 }
24492
24493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24494         LDKPublicKey node_id_ref;
24495         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24496         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24497         LDKChannelReestablish msg_conv;
24498         msg_conv.inner = (void*)(msg & (~1));
24499         msg_conv.is_owned = (msg & 1) || (msg == 0);
24500         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24501         msg_conv = ChannelReestablish_clone(&msg_conv);
24502         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24503         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
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_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
24509         LDKChannelAnnouncement msg_conv;
24510         msg_conv.inner = (void*)(msg & (~1));
24511         msg_conv.is_owned = (msg & 1) || (msg == 0);
24512         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24513         msg_conv = ChannelAnnouncement_clone(&msg_conv);
24514         LDKChannelUpdate update_msg_conv;
24515         update_msg_conv.inner = (void*)(update_msg & (~1));
24516         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
24517         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
24518         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
24519         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24520         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
24521         int64_t ret_ref = (uintptr_t)ret_copy;
24522         return ret_ref;
24523 }
24524
24525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
24526         LDKNodeAnnouncement msg_conv;
24527         msg_conv.inner = (void*)(msg & (~1));
24528         msg_conv.is_owned = (msg & 1) || (msg == 0);
24529         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24530         msg_conv = NodeAnnouncement_clone(&msg_conv);
24531         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24532         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
24533         int64_t ret_ref = (uintptr_t)ret_copy;
24534         return ret_ref;
24535 }
24536
24537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
24538         LDKChannelUpdate msg_conv;
24539         msg_conv.inner = (void*)(msg & (~1));
24540         msg_conv.is_owned = (msg & 1) || (msg == 0);
24541         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24542         msg_conv = ChannelUpdate_clone(&msg_conv);
24543         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24544         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
24545         int64_t ret_ref = (uintptr_t)ret_copy;
24546         return ret_ref;
24547 }
24548
24549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
24550         LDKPublicKey node_id_ref;
24551         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24552         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24553         LDKChannelUpdate msg_conv;
24554         msg_conv.inner = (void*)(msg & (~1));
24555         msg_conv.is_owned = (msg & 1) || (msg == 0);
24556         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24557         msg_conv = ChannelUpdate_clone(&msg_conv);
24558         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24559         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
24560         int64_t ret_ref = (uintptr_t)ret_copy;
24561         return ret_ref;
24562 }
24563
24564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
24565         LDKPublicKey node_id_ref;
24566         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24567         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24568         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
24569         CHECK_ACCESS(action_ptr);
24570         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
24571         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
24572         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24573         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
24574         int64_t ret_ref = (uintptr_t)ret_copy;
24575         return ret_ref;
24576 }
24577
24578 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) {
24579         LDKPublicKey node_id_ref;
24580         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24581         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24582         LDKQueryChannelRange msg_conv;
24583         msg_conv.inner = (void*)(msg & (~1));
24584         msg_conv.is_owned = (msg & 1) || (msg == 0);
24585         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24586         msg_conv = QueryChannelRange_clone(&msg_conv);
24587         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24588         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
24589         int64_t ret_ref = (uintptr_t)ret_copy;
24590         return ret_ref;
24591 }
24592
24593 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) {
24594         LDKPublicKey node_id_ref;
24595         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24596         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24597         LDKQueryShortChannelIds msg_conv;
24598         msg_conv.inner = (void*)(msg & (~1));
24599         msg_conv.is_owned = (msg & 1) || (msg == 0);
24600         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24601         msg_conv = QueryShortChannelIds_clone(&msg_conv);
24602         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24603         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
24604         int64_t ret_ref = (uintptr_t)ret_copy;
24605         return ret_ref;
24606 }
24607
24608 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) {
24609         LDKPublicKey node_id_ref;
24610         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24611         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24612         LDKReplyChannelRange msg_conv;
24613         msg_conv.inner = (void*)(msg & (~1));
24614         msg_conv.is_owned = (msg & 1) || (msg == 0);
24615         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24616         msg_conv = ReplyChannelRange_clone(&msg_conv);
24617         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24618         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
24619         int64_t ret_ref = (uintptr_t)ret_copy;
24620         return ret_ref;
24621 }
24622
24623 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) {
24624         LDKPublicKey node_id_ref;
24625         CHECK((*env)->GetArrayLength(env, node_id) == 33);
24626         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
24627         LDKGossipTimestampFilter msg_conv;
24628         msg_conv.inner = (void*)(msg & (~1));
24629         msg_conv.is_owned = (msg & 1) || (msg == 0);
24630         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
24631         msg_conv = GossipTimestampFilter_clone(&msg_conv);
24632         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
24633         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
24634         int64_t ret_ref = (uintptr_t)ret_copy;
24635         return ret_ref;
24636 }
24637
24638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24639         if ((this_ptr & 1) != 0) return;
24640         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24641         CHECK_ACCESS(this_ptr_ptr);
24642         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
24643         FREE((void*)this_ptr);
24644         MessageSendEventsProvider_free(this_ptr_conv);
24645 }
24646
24647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24648         if ((this_ptr & 1) != 0) return;
24649         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24650         CHECK_ACCESS(this_ptr_ptr);
24651         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
24652         FREE((void*)this_ptr);
24653         EventsProvider_free(this_ptr_conv);
24654 }
24655
24656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24657         if ((this_ptr & 1) != 0) return;
24658         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24659         CHECK_ACCESS(this_ptr_ptr);
24660         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
24661         FREE((void*)this_ptr);
24662         EventHandler_free(this_ptr_conv);
24663 }
24664
24665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24666         if ((this_ptr & 1) != 0) return;
24667         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24668         CHECK_ACCESS(this_ptr_ptr);
24669         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
24670         FREE((void*)this_ptr);
24671         APIError_free(this_ptr_conv);
24672 }
24673
24674 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
24675         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24676         *ret_copy = APIError_clone(arg);
24677 int64_t ret_ref = (uintptr_t)ret_copy;
24678         return ret_ref;
24679 }
24680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24681         LDKAPIError* arg_conv = (LDKAPIError*)arg;
24682         int64_t ret_conv = APIError_clone_ptr(arg_conv);
24683         return ret_conv;
24684 }
24685
24686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24687         LDKAPIError* orig_conv = (LDKAPIError*)orig;
24688         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24689         *ret_copy = APIError_clone(orig_conv);
24690         int64_t ret_ref = (uintptr_t)ret_copy;
24691         return ret_ref;
24692 }
24693
24694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
24695         LDKStr err_conv = java_to_owned_str(env, err);
24696         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24697         *ret_copy = APIError_apimisuse_error(err_conv);
24698         int64_t ret_ref = (uintptr_t)ret_copy;
24699         return ret_ref;
24700 }
24701
24702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
24703         LDKStr err_conv = java_to_owned_str(env, err);
24704         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24705         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
24706         int64_t ret_ref = (uintptr_t)ret_copy;
24707         return ret_ref;
24708 }
24709
24710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
24711         LDKStr err_conv = java_to_owned_str(env, err);
24712         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24713         *ret_copy = APIError_route_error(err_conv);
24714         int64_t ret_ref = (uintptr_t)ret_copy;
24715         return ret_ref;
24716 }
24717
24718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
24719         LDKStr err_conv = java_to_owned_str(env, err);
24720         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24721         *ret_copy = APIError_channel_unavailable(err_conv);
24722         int64_t ret_ref = (uintptr_t)ret_copy;
24723         return ret_ref;
24724 }
24725
24726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
24727         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24728         *ret_copy = APIError_monitor_update_failed();
24729         int64_t ret_ref = (uintptr_t)ret_copy;
24730         return ret_ref;
24731 }
24732
24733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
24734         LDKShutdownScript script_conv;
24735         script_conv.inner = (void*)(script & (~1));
24736         script_conv.is_owned = (script & 1) || (script == 0);
24737         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
24738         script_conv = ShutdownScript_clone(&script_conv);
24739         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
24740         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
24741         int64_t ret_ref = (uintptr_t)ret_copy;
24742         return ret_ref;
24743 }
24744
24745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24746         LDKBigSize this_obj_conv;
24747         this_obj_conv.inner = (void*)(this_obj & (~1));
24748         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24750         BigSize_free(this_obj_conv);
24751 }
24752
24753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
24754         LDKBigSize this_ptr_conv;
24755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24756         this_ptr_conv.is_owned = false;
24757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24758         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
24759         return ret_conv;
24760 }
24761
24762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24763         LDKBigSize this_ptr_conv;
24764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24765         this_ptr_conv.is_owned = false;
24766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24767         BigSize_set_a(&this_ptr_conv, val);
24768 }
24769
24770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
24771         LDKBigSize ret_var = BigSize_new(a_arg);
24772         int64_t ret_ref = 0;
24773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24776         ret_ref = (uintptr_t)ret_var.inner;
24777         if (ret_var.is_owned) {
24778                 ret_ref |= 1;
24779         }
24780         return ret_ref;
24781 }
24782
24783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
24784         LDKu8slice msg_ref;
24785         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24786         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24787         unsigned char sk_arr[32];
24788         CHECK((*env)->GetArrayLength(env, sk) == 32);
24789         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
24790         unsigned char (*sk_ref)[32] = &sk_arr;
24791         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
24792         *ret_conv = sign(msg_ref, sk_ref);
24793         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24794         return (int64_t)ret_conv;
24795 }
24796
24797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
24798         LDKu8slice msg_ref;
24799         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24800         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24801         LDKStr sig_conv = java_to_owned_str(env, sig);
24802         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
24803         *ret_conv = recover_pk(msg_ref, sig_conv);
24804         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24805         return (int64_t)ret_conv;
24806 }
24807
24808 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
24809         LDKu8slice msg_ref;
24810         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
24811         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
24812         LDKStr sig_conv = java_to_owned_str(env, sig);
24813         LDKPublicKey pk_ref;
24814         CHECK((*env)->GetArrayLength(env, pk) == 33);
24815         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
24816         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
24817         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24818         return ret_conv;
24819 }
24820
24821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
24822         LDKu8slice hrp_bytes_ref;
24823         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
24824         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
24825         LDKCVec_u5Z data_without_signature_constr;
24826         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
24827         if (data_without_signature_constr.datalen > 0)
24828                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
24829         else
24830                 data_without_signature_constr.data = NULL;
24831         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
24832         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
24833                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
24834                 
24835                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
24836         }
24837         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
24838         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
24839         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24840         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24841         CVec_u8Z_free(ret_var);
24842         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
24843         return ret_arr;
24844 }
24845
24846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24847         if ((this_ptr & 1) != 0) return;
24848         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24849         CHECK_ACCESS(this_ptr_ptr);
24850         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
24851         FREE((void*)this_ptr);
24852         Persister_free(this_ptr_conv);
24853 }
24854
24855 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24856         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
24857         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
24858         return ret_conv;
24859 }
24860
24861 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
24862         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
24863         return ret_conv;
24864 }
24865
24866 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
24867         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
24868         return ret_conv;
24869 }
24870
24871 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
24872         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
24873         return ret_conv;
24874 }
24875
24876 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
24877         jclass ret_conv = LDKLevel_to_java(env, Level_info());
24878         return ret_conv;
24879 }
24880
24881 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
24882         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
24883         return ret_conv;
24884 }
24885
24886 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
24887         jclass ret_conv = LDKLevel_to_java(env, Level_error());
24888         return ret_conv;
24889 }
24890
24891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24892         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
24893         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
24894         jboolean ret_conv = Level_eq(a_conv, b_conv);
24895         return ret_conv;
24896 }
24897
24898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
24899         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
24900         int64_t ret_conv = Level_hash(o_conv);
24901         return ret_conv;
24902 }
24903
24904 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
24905         jclass ret_conv = LDKLevel_to_java(env, Level_max());
24906         return ret_conv;
24907 }
24908
24909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24910         LDKRecord this_obj_conv;
24911         this_obj_conv.inner = (void*)(this_obj & (~1));
24912         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24914         Record_free(this_obj_conv);
24915 }
24916
24917 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
24918         LDKRecord this_ptr_conv;
24919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24920         this_ptr_conv.is_owned = false;
24921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24922         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
24923         return ret_conv;
24924 }
24925
24926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
24927         LDKRecord this_ptr_conv;
24928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24929         this_ptr_conv.is_owned = false;
24930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24931         LDKLevel val_conv = LDKLevel_from_java(env, val);
24932         Record_set_level(&this_ptr_conv, val_conv);
24933 }
24934
24935 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
24936         LDKRecord this_ptr_conv;
24937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24938         this_ptr_conv.is_owned = false;
24939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24940         LDKStr ret_str = Record_get_args(&this_ptr_conv);
24941         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24942         Str_free(ret_str);
24943         return ret_conv;
24944 }
24945
24946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24947         LDKRecord this_ptr_conv;
24948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24949         this_ptr_conv.is_owned = false;
24950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24951         LDKStr val_conv = java_to_owned_str(env, val);
24952         Record_set_args(&this_ptr_conv, val_conv);
24953 }
24954
24955 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
24956         LDKRecord this_ptr_conv;
24957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24958         this_ptr_conv.is_owned = false;
24959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24960         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
24961         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24962         Str_free(ret_str);
24963         return ret_conv;
24964 }
24965
24966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24967         LDKRecord this_ptr_conv;
24968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24969         this_ptr_conv.is_owned = false;
24970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24971         LDKStr val_conv = java_to_owned_str(env, val);
24972         Record_set_module_path(&this_ptr_conv, val_conv);
24973 }
24974
24975 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
24976         LDKRecord this_ptr_conv;
24977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24978         this_ptr_conv.is_owned = false;
24979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24980         LDKStr ret_str = Record_get_file(&this_ptr_conv);
24981         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24982         Str_free(ret_str);
24983         return ret_conv;
24984 }
24985
24986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24987         LDKRecord this_ptr_conv;
24988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24989         this_ptr_conv.is_owned = false;
24990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24991         LDKStr val_conv = java_to_owned_str(env, val);
24992         Record_set_file(&this_ptr_conv, val_conv);
24993 }
24994
24995 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
24996         LDKRecord this_ptr_conv;
24997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24998         this_ptr_conv.is_owned = false;
24999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25000         int32_t ret_conv = Record_get_line(&this_ptr_conv);
25001         return ret_conv;
25002 }
25003
25004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25005         LDKRecord this_ptr_conv;
25006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25007         this_ptr_conv.is_owned = false;
25008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25009         Record_set_line(&this_ptr_conv, val);
25010 }
25011
25012 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
25013         LDKRecord ret_var = Record_clone(arg);
25014 int64_t ret_ref = 0;
25015 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25016 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25017 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25018 ret_ref = (uintptr_t)ret_var.inner;
25019 if (ret_var.is_owned) {
25020         ret_ref |= 1;
25021 }
25022         return ret_ref;
25023 }
25024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25025         LDKRecord arg_conv;
25026         arg_conv.inner = (void*)(arg & (~1));
25027         arg_conv.is_owned = false;
25028         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25029         int64_t ret_conv = Record_clone_ptr(&arg_conv);
25030         return ret_conv;
25031 }
25032
25033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25034         LDKRecord orig_conv;
25035         orig_conv.inner = (void*)(orig & (~1));
25036         orig_conv.is_owned = false;
25037         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25038         LDKRecord ret_var = Record_clone(&orig_conv);
25039         int64_t ret_ref = 0;
25040         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25041         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25043         ret_ref = (uintptr_t)ret_var.inner;
25044         if (ret_var.is_owned) {
25045                 ret_ref |= 1;
25046         }
25047         return ret_ref;
25048 }
25049
25050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25051         if ((this_ptr & 1) != 0) return;
25052         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25053         CHECK_ACCESS(this_ptr_ptr);
25054         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
25055         FREE((void*)this_ptr);
25056         Logger_free(this_ptr_conv);
25057 }
25058
25059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25060         LDKChannelHandshakeConfig this_obj_conv;
25061         this_obj_conv.inner = (void*)(this_obj & (~1));
25062         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25064         ChannelHandshakeConfig_free(this_obj_conv);
25065 }
25066
25067 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
25068         LDKChannelHandshakeConfig this_ptr_conv;
25069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25070         this_ptr_conv.is_owned = false;
25071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25072         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
25073         return ret_conv;
25074 }
25075
25076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25077         LDKChannelHandshakeConfig this_ptr_conv;
25078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25079         this_ptr_conv.is_owned = false;
25080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25081         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
25082 }
25083
25084 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25085         LDKChannelHandshakeConfig this_ptr_conv;
25086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25087         this_ptr_conv.is_owned = false;
25088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25089         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
25090         return ret_conv;
25091 }
25092
25093 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) {
25094         LDKChannelHandshakeConfig this_ptr_conv;
25095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25096         this_ptr_conv.is_owned = false;
25097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25098         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
25099 }
25100
25101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25102         LDKChannelHandshakeConfig this_ptr_conv;
25103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25104         this_ptr_conv.is_owned = false;
25105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25106         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
25107         return ret_conv;
25108 }
25109
25110 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) {
25111         LDKChannelHandshakeConfig this_ptr_conv;
25112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25113         this_ptr_conv.is_owned = false;
25114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25115         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
25116 }
25117
25118 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) {
25119         LDKChannelHandshakeConfig this_ptr_conv;
25120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25121         this_ptr_conv.is_owned = false;
25122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25123         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
25124         return ret_conv;
25125 }
25126
25127 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) {
25128         LDKChannelHandshakeConfig this_ptr_conv;
25129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25130         this_ptr_conv.is_owned = false;
25131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25132         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
25133 }
25134
25135 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
25136         LDKChannelHandshakeConfig this_ptr_conv;
25137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25138         this_ptr_conv.is_owned = false;
25139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25140         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
25141         return ret_conv;
25142 }
25143
25144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25145         LDKChannelHandshakeConfig this_ptr_conv;
25146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25147         this_ptr_conv.is_owned = false;
25148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25149         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
25150 }
25151
25152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
25153         LDKChannelHandshakeConfig this_ptr_conv;
25154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25155         this_ptr_conv.is_owned = false;
25156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25157         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
25158         return ret_conv;
25159 }
25160
25161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25162         LDKChannelHandshakeConfig this_ptr_conv;
25163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25164         this_ptr_conv.is_owned = false;
25165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25166         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
25167 }
25168
25169 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25170         LDKChannelHandshakeConfig this_ptr_conv;
25171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25172         this_ptr_conv.is_owned = false;
25173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25174         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
25175         return ret_conv;
25176 }
25177
25178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25179         LDKChannelHandshakeConfig this_ptr_conv;
25180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25181         this_ptr_conv.is_owned = false;
25182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25183         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
25184 }
25185
25186 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) {
25187         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);
25188         int64_t ret_ref = 0;
25189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25192         ret_ref = (uintptr_t)ret_var.inner;
25193         if (ret_var.is_owned) {
25194                 ret_ref |= 1;
25195         }
25196         return ret_ref;
25197 }
25198
25199 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
25200         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
25201 int64_t ret_ref = 0;
25202 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25203 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25204 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25205 ret_ref = (uintptr_t)ret_var.inner;
25206 if (ret_var.is_owned) {
25207         ret_ref |= 1;
25208 }
25209         return ret_ref;
25210 }
25211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25212         LDKChannelHandshakeConfig arg_conv;
25213         arg_conv.inner = (void*)(arg & (~1));
25214         arg_conv.is_owned = false;
25215         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25216         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
25217         return ret_conv;
25218 }
25219
25220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25221         LDKChannelHandshakeConfig orig_conv;
25222         orig_conv.inner = (void*)(orig & (~1));
25223         orig_conv.is_owned = false;
25224         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25225         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
25226         int64_t ret_ref = 0;
25227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25230         ret_ref = (uintptr_t)ret_var.inner;
25231         if (ret_var.is_owned) {
25232                 ret_ref |= 1;
25233         }
25234         return ret_ref;
25235 }
25236
25237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
25238         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
25239         int64_t ret_ref = 0;
25240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25243         ret_ref = (uintptr_t)ret_var.inner;
25244         if (ret_var.is_owned) {
25245                 ret_ref |= 1;
25246         }
25247         return ret_ref;
25248 }
25249
25250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25251         LDKChannelHandshakeLimits this_obj_conv;
25252         this_obj_conv.inner = (void*)(this_obj & (~1));
25253         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25255         ChannelHandshakeLimits_free(this_obj_conv);
25256 }
25257
25258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25259         LDKChannelHandshakeLimits this_ptr_conv;
25260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25261         this_ptr_conv.is_owned = false;
25262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25263         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
25264         return ret_conv;
25265 }
25266
25267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25268         LDKChannelHandshakeLimits this_ptr_conv;
25269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25270         this_ptr_conv.is_owned = false;
25271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25272         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
25273 }
25274
25275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25276         LDKChannelHandshakeLimits this_ptr_conv;
25277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25278         this_ptr_conv.is_owned = false;
25279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25280         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
25281         return ret_conv;
25282 }
25283
25284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25285         LDKChannelHandshakeLimits this_ptr_conv;
25286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25287         this_ptr_conv.is_owned = false;
25288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25289         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
25290 }
25291
25292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25293         LDKChannelHandshakeLimits this_ptr_conv;
25294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25295         this_ptr_conv.is_owned = false;
25296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25297         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
25298         return ret_conv;
25299 }
25300
25301 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) {
25302         LDKChannelHandshakeLimits this_ptr_conv;
25303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25304         this_ptr_conv.is_owned = false;
25305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25306         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
25307 }
25308
25309 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) {
25310         LDKChannelHandshakeLimits this_ptr_conv;
25311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25312         this_ptr_conv.is_owned = false;
25313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25314         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
25315         return ret_conv;
25316 }
25317
25318 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) {
25319         LDKChannelHandshakeLimits this_ptr_conv;
25320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25321         this_ptr_conv.is_owned = false;
25322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25323         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
25324 }
25325
25326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25327         LDKChannelHandshakeLimits this_ptr_conv;
25328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25329         this_ptr_conv.is_owned = false;
25330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25331         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
25332         return ret_conv;
25333 }
25334
25335 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) {
25336         LDKChannelHandshakeLimits this_ptr_conv;
25337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25338         this_ptr_conv.is_owned = false;
25339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25340         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
25341 }
25342
25343 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25344         LDKChannelHandshakeLimits this_ptr_conv;
25345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25346         this_ptr_conv.is_owned = false;
25347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25348         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
25349         return ret_conv;
25350 }
25351
25352 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) {
25353         LDKChannelHandshakeLimits this_ptr_conv;
25354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25355         this_ptr_conv.is_owned = false;
25356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25357         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
25358 }
25359
25360 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
25361         LDKChannelHandshakeLimits this_ptr_conv;
25362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25363         this_ptr_conv.is_owned = false;
25364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25365         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
25366         return ret_conv;
25367 }
25368
25369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25370         LDKChannelHandshakeLimits this_ptr_conv;
25371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25372         this_ptr_conv.is_owned = false;
25373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25374         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
25375 }
25376
25377 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
25378         LDKChannelHandshakeLimits this_ptr_conv;
25379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25380         this_ptr_conv.is_owned = false;
25381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25382         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
25383         return ret_conv;
25384 }
25385
25386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25387         LDKChannelHandshakeLimits this_ptr_conv;
25388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25389         this_ptr_conv.is_owned = false;
25390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25391         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
25392 }
25393
25394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
25395         LDKChannelHandshakeLimits this_ptr_conv;
25396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25397         this_ptr_conv.is_owned = false;
25398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25399         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
25400         return ret_conv;
25401 }
25402
25403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25404         LDKChannelHandshakeLimits this_ptr_conv;
25405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25406         this_ptr_conv.is_owned = false;
25407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25408         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
25409 }
25410
25411 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25412         LDKChannelHandshakeLimits this_ptr_conv;
25413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25414         this_ptr_conv.is_owned = false;
25415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25416         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
25417         return ret_conv;
25418 }
25419
25420 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) {
25421         LDKChannelHandshakeLimits this_ptr_conv;
25422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25423         this_ptr_conv.is_owned = false;
25424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25425         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
25426 }
25427
25428 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) {
25429         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);
25430         int64_t ret_ref = 0;
25431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25434         ret_ref = (uintptr_t)ret_var.inner;
25435         if (ret_var.is_owned) {
25436                 ret_ref |= 1;
25437         }
25438         return ret_ref;
25439 }
25440
25441 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
25442         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
25443 int64_t ret_ref = 0;
25444 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25445 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25446 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25447 ret_ref = (uintptr_t)ret_var.inner;
25448 if (ret_var.is_owned) {
25449         ret_ref |= 1;
25450 }
25451         return ret_ref;
25452 }
25453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25454         LDKChannelHandshakeLimits arg_conv;
25455         arg_conv.inner = (void*)(arg & (~1));
25456         arg_conv.is_owned = false;
25457         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25458         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
25459         return ret_conv;
25460 }
25461
25462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25463         LDKChannelHandshakeLimits orig_conv;
25464         orig_conv.inner = (void*)(orig & (~1));
25465         orig_conv.is_owned = false;
25466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25467         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
25468         int64_t ret_ref = 0;
25469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25472         ret_ref = (uintptr_t)ret_var.inner;
25473         if (ret_var.is_owned) {
25474                 ret_ref |= 1;
25475         }
25476         return ret_ref;
25477 }
25478
25479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
25480         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
25481         int64_t ret_ref = 0;
25482         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25483         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25485         ret_ref = (uintptr_t)ret_var.inner;
25486         if (ret_var.is_owned) {
25487                 ret_ref |= 1;
25488         }
25489         return ret_ref;
25490 }
25491
25492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25493         LDKChannelConfig this_obj_conv;
25494         this_obj_conv.inner = (void*)(this_obj & (~1));
25495         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25497         ChannelConfig_free(this_obj_conv);
25498 }
25499
25500 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
25501         LDKChannelConfig this_ptr_conv;
25502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25503         this_ptr_conv.is_owned = false;
25504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25505         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
25506         return ret_conv;
25507 }
25508
25509 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) {
25510         LDKChannelConfig this_ptr_conv;
25511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25512         this_ptr_conv.is_owned = false;
25513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25514         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
25515 }
25516
25517 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25518         LDKChannelConfig this_ptr_conv;
25519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25520         this_ptr_conv.is_owned = false;
25521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25522         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
25523         return ret_conv;
25524 }
25525
25526 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) {
25527         LDKChannelConfig this_ptr_conv;
25528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25529         this_ptr_conv.is_owned = false;
25530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25531         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
25532 }
25533
25534 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
25535         LDKChannelConfig this_ptr_conv;
25536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25537         this_ptr_conv.is_owned = false;
25538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25539         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
25540         return ret_conv;
25541 }
25542
25543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25544         LDKChannelConfig this_ptr_conv;
25545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25546         this_ptr_conv.is_owned = false;
25547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25548         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
25549 }
25550
25551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25552         LDKChannelConfig this_ptr_conv;
25553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25554         this_ptr_conv.is_owned = false;
25555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25556         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
25557         return ret_conv;
25558 }
25559
25560 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) {
25561         LDKChannelConfig this_ptr_conv;
25562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25563         this_ptr_conv.is_owned = false;
25564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25565         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
25566 }
25567
25568 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) {
25569         LDKChannelConfig this_ptr_conv;
25570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25571         this_ptr_conv.is_owned = false;
25572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25573         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
25574         return ret_conv;
25575 }
25576
25577 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) {
25578         LDKChannelConfig this_ptr_conv;
25579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25580         this_ptr_conv.is_owned = false;
25581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25582         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
25583 }
25584
25585 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) {
25586         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);
25587         int64_t ret_ref = 0;
25588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25591         ret_ref = (uintptr_t)ret_var.inner;
25592         if (ret_var.is_owned) {
25593                 ret_ref |= 1;
25594         }
25595         return ret_ref;
25596 }
25597
25598 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
25599         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
25600 int64_t ret_ref = 0;
25601 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25602 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25603 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25604 ret_ref = (uintptr_t)ret_var.inner;
25605 if (ret_var.is_owned) {
25606         ret_ref |= 1;
25607 }
25608         return ret_ref;
25609 }
25610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25611         LDKChannelConfig arg_conv;
25612         arg_conv.inner = (void*)(arg & (~1));
25613         arg_conv.is_owned = false;
25614         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25615         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
25616         return ret_conv;
25617 }
25618
25619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25620         LDKChannelConfig orig_conv;
25621         orig_conv.inner = (void*)(orig & (~1));
25622         orig_conv.is_owned = false;
25623         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25624         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
25625         int64_t ret_ref = 0;
25626         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25627         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25629         ret_ref = (uintptr_t)ret_var.inner;
25630         if (ret_var.is_owned) {
25631                 ret_ref |= 1;
25632         }
25633         return ret_ref;
25634 }
25635
25636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
25637         LDKChannelConfig ret_var = ChannelConfig_default();
25638         int64_t ret_ref = 0;
25639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25642         ret_ref = (uintptr_t)ret_var.inner;
25643         if (ret_var.is_owned) {
25644                 ret_ref |= 1;
25645         }
25646         return ret_ref;
25647 }
25648
25649 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
25650         LDKChannelConfig obj_conv;
25651         obj_conv.inner = (void*)(obj & (~1));
25652         obj_conv.is_owned = false;
25653         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25654         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
25655         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25656         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25657         CVec_u8Z_free(ret_var);
25658         return ret_arr;
25659 }
25660
25661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25662         LDKu8slice ser_ref;
25663         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25664         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25665         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
25666         *ret_conv = ChannelConfig_read(ser_ref);
25667         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25668         return (int64_t)ret_conv;
25669 }
25670
25671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25672         LDKUserConfig this_obj_conv;
25673         this_obj_conv.inner = (void*)(this_obj & (~1));
25674         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25676         UserConfig_free(this_obj_conv);
25677 }
25678
25679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
25680         LDKUserConfig this_ptr_conv;
25681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25682         this_ptr_conv.is_owned = false;
25683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25684         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
25685         int64_t ret_ref = 0;
25686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25689         ret_ref = (uintptr_t)ret_var.inner;
25690         if (ret_var.is_owned) {
25691                 ret_ref |= 1;
25692         }
25693         return ret_ref;
25694 }
25695
25696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25697         LDKUserConfig this_ptr_conv;
25698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25699         this_ptr_conv.is_owned = false;
25700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25701         LDKChannelHandshakeConfig val_conv;
25702         val_conv.inner = (void*)(val & (~1));
25703         val_conv.is_owned = (val & 1) || (val == 0);
25704         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25705         val_conv = ChannelHandshakeConfig_clone(&val_conv);
25706         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
25707 }
25708
25709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
25710         LDKUserConfig this_ptr_conv;
25711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25712         this_ptr_conv.is_owned = false;
25713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25714         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
25715         int64_t ret_ref = 0;
25716         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25717         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25719         ret_ref = (uintptr_t)ret_var.inner;
25720         if (ret_var.is_owned) {
25721                 ret_ref |= 1;
25722         }
25723         return ret_ref;
25724 }
25725
25726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25727         LDKUserConfig this_ptr_conv;
25728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25729         this_ptr_conv.is_owned = false;
25730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25731         LDKChannelHandshakeLimits val_conv;
25732         val_conv.inner = (void*)(val & (~1));
25733         val_conv.is_owned = (val & 1) || (val == 0);
25734         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25735         val_conv = ChannelHandshakeLimits_clone(&val_conv);
25736         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
25737 }
25738
25739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
25740         LDKUserConfig this_ptr_conv;
25741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25742         this_ptr_conv.is_owned = false;
25743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25744         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
25745         int64_t ret_ref = 0;
25746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25749         ret_ref = (uintptr_t)ret_var.inner;
25750         if (ret_var.is_owned) {
25751                 ret_ref |= 1;
25752         }
25753         return ret_ref;
25754 }
25755
25756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25757         LDKUserConfig this_ptr_conv;
25758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25759         this_ptr_conv.is_owned = false;
25760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25761         LDKChannelConfig val_conv;
25762         val_conv.inner = (void*)(val & (~1));
25763         val_conv.is_owned = (val & 1) || (val == 0);
25764         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25765         val_conv = ChannelConfig_clone(&val_conv);
25766         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
25767 }
25768
25769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25770         LDKUserConfig this_ptr_conv;
25771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25772         this_ptr_conv.is_owned = false;
25773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25774         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
25775         return ret_conv;
25776 }
25777
25778 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) {
25779         LDKUserConfig this_ptr_conv;
25780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25781         this_ptr_conv.is_owned = false;
25782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25783         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
25784 }
25785
25786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25787         LDKUserConfig this_ptr_conv;
25788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25789         this_ptr_conv.is_owned = false;
25790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25791         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
25792         return ret_conv;
25793 }
25794
25795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25796         LDKUserConfig this_ptr_conv;
25797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25798         this_ptr_conv.is_owned = false;
25799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25800         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
25801 }
25802
25803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
25804         LDKUserConfig this_ptr_conv;
25805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25806         this_ptr_conv.is_owned = false;
25807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25808         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
25809         return ret_conv;
25810 }
25811
25812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
25813         LDKUserConfig this_ptr_conv;
25814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25815         this_ptr_conv.is_owned = false;
25816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25817         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
25818 }
25819
25820 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) {
25821         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
25822         channel_handshake_config_arg_conv.inner = (void*)(channel_handshake_config_arg & (~1));
25823         channel_handshake_config_arg_conv.is_owned = (channel_handshake_config_arg & 1) || (channel_handshake_config_arg == 0);
25824         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
25825         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
25826         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
25827         channel_handshake_limits_arg_conv.inner = (void*)(channel_handshake_limits_arg & (~1));
25828         channel_handshake_limits_arg_conv.is_owned = (channel_handshake_limits_arg & 1) || (channel_handshake_limits_arg == 0);
25829         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
25830         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
25831         LDKChannelConfig channel_config_arg_conv;
25832         channel_config_arg_conv.inner = (void*)(channel_config_arg & (~1));
25833         channel_config_arg_conv.is_owned = (channel_config_arg & 1) || (channel_config_arg == 0);
25834         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
25835         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
25836         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);
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 UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
25849         LDKUserConfig ret_var = UserConfig_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_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25861         LDKUserConfig 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 = UserConfig_clone_ptr(&arg_conv);
25866         return ret_conv;
25867 }
25868
25869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25870         LDKUserConfig 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         LDKUserConfig ret_var = UserConfig_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_UserConfig_1default(JNIEnv *env, jclass clz) {
25887         LDKUserConfig ret_var = UserConfig_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_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25900         LDKBestBlock 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         BestBlock_free(this_obj_conv);
25905 }
25906
25907 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
25908         LDKBestBlock ret_var = BestBlock_clone(arg);
25909 int64_t ret_ref = 0;
25910 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25911 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25912 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25913 ret_ref = (uintptr_t)ret_var.inner;
25914 if (ret_var.is_owned) {
25915         ret_ref |= 1;
25916 }
25917         return ret_ref;
25918 }
25919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25920         LDKBestBlock arg_conv;
25921         arg_conv.inner = (void*)(arg & (~1));
25922         arg_conv.is_owned = false;
25923         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25924         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
25925         return ret_conv;
25926 }
25927
25928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25929         LDKBestBlock orig_conv;
25930         orig_conv.inner = (void*)(orig & (~1));
25931         orig_conv.is_owned = false;
25932         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25933         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
25934         int64_t ret_ref = 0;
25935         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25936         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25938         ret_ref = (uintptr_t)ret_var.inner;
25939         if (ret_var.is_owned) {
25940                 ret_ref |= 1;
25941         }
25942         return ret_ref;
25943 }
25944
25945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
25946         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
25947         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
25948         int64_t ret_ref = 0;
25949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25952         ret_ref = (uintptr_t)ret_var.inner;
25953         if (ret_var.is_owned) {
25954                 ret_ref |= 1;
25955         }
25956         return ret_ref;
25957 }
25958
25959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
25960         LDKThirtyTwoBytes block_hash_ref;
25961         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
25962         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
25963         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
25964         int64_t ret_ref = 0;
25965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25968         ret_ref = (uintptr_t)ret_var.inner;
25969         if (ret_var.is_owned) {
25970                 ret_ref |= 1;
25971         }
25972         return ret_ref;
25973 }
25974
25975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25976         LDKBestBlock this_arg_conv;
25977         this_arg_conv.inner = (void*)(this_arg & (~1));
25978         this_arg_conv.is_owned = false;
25979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25980         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25981         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
25982         return ret_arr;
25983 }
25984
25985 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
25986         LDKBestBlock this_arg_conv;
25987         this_arg_conv.inner = (void*)(this_arg & (~1));
25988         this_arg_conv.is_owned = false;
25989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25990         int32_t ret_conv = BestBlock_height(&this_arg_conv);
25991         return ret_conv;
25992 }
25993
25994 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25995         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
25996         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
25997         return ret_conv;
25998 }
25999
26000 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
26001         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
26002         return ret_conv;
26003 }
26004
26005 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
26006         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
26007         return ret_conv;
26008 }
26009
26010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26011         if ((this_ptr & 1) != 0) return;
26012         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26013         CHECK_ACCESS(this_ptr_ptr);
26014         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
26015         FREE((void*)this_ptr);
26016         Access_free(this_ptr_conv);
26017 }
26018
26019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26020         if ((this_ptr & 1) != 0) return;
26021         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26022         CHECK_ACCESS(this_ptr_ptr);
26023         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
26024         FREE((void*)this_ptr);
26025         Listen_free(this_ptr_conv);
26026 }
26027
26028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26029         if ((this_ptr & 1) != 0) return;
26030         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26031         CHECK_ACCESS(this_ptr_ptr);
26032         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
26033         FREE((void*)this_ptr);
26034         Confirm_free(this_ptr_conv);
26035 }
26036
26037 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26038         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
26039         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
26040         return ret_conv;
26041 }
26042
26043 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
26044         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
26045         return ret_conv;
26046 }
26047
26048 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
26049         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
26050         return ret_conv;
26051 }
26052
26053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26054         if ((this_ptr & 1) != 0) return;
26055         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26056         CHECK_ACCESS(this_ptr_ptr);
26057         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
26058         FREE((void*)this_ptr);
26059         Watch_free(this_ptr_conv);
26060 }
26061
26062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26063         if ((this_ptr & 1) != 0) return;
26064         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26065         CHECK_ACCESS(this_ptr_ptr);
26066         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
26067         FREE((void*)this_ptr);
26068         Filter_free(this_ptr_conv);
26069 }
26070
26071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26072         LDKWatchedOutput this_obj_conv;
26073         this_obj_conv.inner = (void*)(this_obj & (~1));
26074         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26076         WatchedOutput_free(this_obj_conv);
26077 }
26078
26079 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
26080         LDKWatchedOutput this_ptr_conv;
26081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26082         this_ptr_conv.is_owned = false;
26083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26084         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26085         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
26086         return ret_arr;
26087 }
26088
26089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26090         LDKWatchedOutput this_ptr_conv;
26091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26092         this_ptr_conv.is_owned = false;
26093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26094         LDKThirtyTwoBytes val_ref;
26095         CHECK((*env)->GetArrayLength(env, val) == 32);
26096         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26097         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
26098 }
26099
26100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26101         LDKWatchedOutput this_ptr_conv;
26102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26103         this_ptr_conv.is_owned = false;
26104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26105         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
26106         int64_t ret_ref = 0;
26107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26110         ret_ref = (uintptr_t)ret_var.inner;
26111         if (ret_var.is_owned) {
26112                 ret_ref |= 1;
26113         }
26114         return ret_ref;
26115 }
26116
26117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26118         LDKWatchedOutput this_ptr_conv;
26119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26120         this_ptr_conv.is_owned = false;
26121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26122         LDKOutPoint val_conv;
26123         val_conv.inner = (void*)(val & (~1));
26124         val_conv.is_owned = (val & 1) || (val == 0);
26125         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26126         val_conv = OutPoint_clone(&val_conv);
26127         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
26128 }
26129
26130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26131         LDKWatchedOutput this_ptr_conv;
26132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26133         this_ptr_conv.is_owned = false;
26134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26135         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
26136         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26137         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26138         return ret_arr;
26139 }
26140
26141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26142         LDKWatchedOutput this_ptr_conv;
26143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26144         this_ptr_conv.is_owned = false;
26145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26146         LDKCVec_u8Z val_ref;
26147         val_ref.datalen = (*env)->GetArrayLength(env, val);
26148         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
26149         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
26150         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
26151 }
26152
26153 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) {
26154         LDKThirtyTwoBytes block_hash_arg_ref;
26155         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
26156         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
26157         LDKOutPoint outpoint_arg_conv;
26158         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26159         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26160         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26161         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26162         LDKCVec_u8Z script_pubkey_arg_ref;
26163         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
26164         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
26165         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
26166         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
26167         int64_t ret_ref = 0;
26168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26171         ret_ref = (uintptr_t)ret_var.inner;
26172         if (ret_var.is_owned) {
26173                 ret_ref |= 1;
26174         }
26175         return ret_ref;
26176 }
26177
26178 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
26179         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
26180 int64_t ret_ref = 0;
26181 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26182 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26183 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26184 ret_ref = (uintptr_t)ret_var.inner;
26185 if (ret_var.is_owned) {
26186         ret_ref |= 1;
26187 }
26188         return ret_ref;
26189 }
26190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26191         LDKWatchedOutput arg_conv;
26192         arg_conv.inner = (void*)(arg & (~1));
26193         arg_conv.is_owned = false;
26194         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26195         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
26196         return ret_conv;
26197 }
26198
26199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26200         LDKWatchedOutput orig_conv;
26201         orig_conv.inner = (void*)(orig & (~1));
26202         orig_conv.is_owned = false;
26203         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26204         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
26205         int64_t ret_ref = 0;
26206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26209         ret_ref = (uintptr_t)ret_var.inner;
26210         if (ret_var.is_owned) {
26211                 ret_ref |= 1;
26212         }
26213         return ret_ref;
26214 }
26215
26216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
26217         LDKWatchedOutput o_conv;
26218         o_conv.inner = (void*)(o & (~1));
26219         o_conv.is_owned = false;
26220         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26221         int64_t ret_conv = WatchedOutput_hash(&o_conv);
26222         return ret_conv;
26223 }
26224
26225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26226         if ((this_ptr & 1) != 0) return;
26227         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26228         CHECK_ACCESS(this_ptr_ptr);
26229         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
26230         FREE((void*)this_ptr);
26231         BroadcasterInterface_free(this_ptr_conv);
26232 }
26233
26234 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26235         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
26236         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
26237         return ret_conv;
26238 }
26239
26240 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
26241         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
26242         return ret_conv;
26243 }
26244
26245 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
26246         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
26247         return ret_conv;
26248 }
26249
26250 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
26251         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
26252         return ret_conv;
26253 }
26254
26255 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26256         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
26257         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
26258         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
26259         return ret_conv;
26260 }
26261
26262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26263         if ((this_ptr & 1) != 0) return;
26264         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26265         CHECK_ACCESS(this_ptr_ptr);
26266         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
26267         FREE((void*)this_ptr);
26268         FeeEstimator_free(this_ptr_conv);
26269 }
26270
26271 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26272         LDKMonitorUpdateId this_obj_conv;
26273         this_obj_conv.inner = (void*)(this_obj & (~1));
26274         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26276         MonitorUpdateId_free(this_obj_conv);
26277 }
26278
26279 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
26280         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
26281 int64_t ret_ref = 0;
26282 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26283 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26284 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26285 ret_ref = (uintptr_t)ret_var.inner;
26286 if (ret_var.is_owned) {
26287         ret_ref |= 1;
26288 }
26289         return ret_ref;
26290 }
26291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26292         LDKMonitorUpdateId arg_conv;
26293         arg_conv.inner = (void*)(arg & (~1));
26294         arg_conv.is_owned = false;
26295         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26296         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
26297         return ret_conv;
26298 }
26299
26300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26301         LDKMonitorUpdateId orig_conv;
26302         orig_conv.inner = (void*)(orig & (~1));
26303         orig_conv.is_owned = false;
26304         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26305         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
26306         int64_t ret_ref = 0;
26307         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26308         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26310         ret_ref = (uintptr_t)ret_var.inner;
26311         if (ret_var.is_owned) {
26312                 ret_ref |= 1;
26313         }
26314         return ret_ref;
26315 }
26316
26317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
26318         LDKMonitorUpdateId o_conv;
26319         o_conv.inner = (void*)(o & (~1));
26320         o_conv.is_owned = false;
26321         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26322         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
26323         return ret_conv;
26324 }
26325
26326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26327         LDKMonitorUpdateId a_conv;
26328         a_conv.inner = (void*)(a & (~1));
26329         a_conv.is_owned = false;
26330         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26331         LDKMonitorUpdateId b_conv;
26332         b_conv.inner = (void*)(b & (~1));
26333         b_conv.is_owned = false;
26334         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26335         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
26336         return ret_conv;
26337 }
26338
26339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26340         if ((this_ptr & 1) != 0) return;
26341         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26342         CHECK_ACCESS(this_ptr_ptr);
26343         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
26344         FREE((void*)this_ptr);
26345         Persist_free(this_ptr_conv);
26346 }
26347
26348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26349         LDKLockedChannelMonitor this_obj_conv;
26350         this_obj_conv.inner = (void*)(this_obj & (~1));
26351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26353         LockedChannelMonitor_free(this_obj_conv);
26354 }
26355
26356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26357         LDKChainMonitor this_obj_conv;
26358         this_obj_conv.inner = (void*)(this_obj & (~1));
26359         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26361         ChainMonitor_free(this_obj_conv);
26362 }
26363
26364 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) {
26365         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
26366         CHECK_ACCESS(chain_source_ptr);
26367         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
26368         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
26369         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
26370                 // Manually implement clone for Java trait instances
26371                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
26372                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26373                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
26374                 }
26375         }
26376         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26377         CHECK_ACCESS(broadcaster_ptr);
26378         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26379         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26380                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26381                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26382         }
26383         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26384         CHECK_ACCESS(logger_ptr);
26385         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26386         if (logger_conv.free == LDKLogger_JCalls_free) {
26387                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26388                 LDKLogger_JCalls_cloned(&logger_conv);
26389         }
26390         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
26391         CHECK_ACCESS(feeest_ptr);
26392         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
26393         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
26394                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26395                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
26396         }
26397         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
26398         CHECK_ACCESS(persister_ptr);
26399         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
26400         if (persister_conv.free == LDKPersist_JCalls_free) {
26401                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26402                 LDKPersist_JCalls_cloned(&persister_conv);
26403         }
26404         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
26405         int64_t ret_ref = 0;
26406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26409         ret_ref = (uintptr_t)ret_var.inner;
26410         if (ret_var.is_owned) {
26411                 ret_ref |= 1;
26412         }
26413         return ret_ref;
26414 }
26415
26416 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) {
26417         LDKChainMonitor this_arg_conv;
26418         this_arg_conv.inner = (void*)(this_arg & (~1));
26419         this_arg_conv.is_owned = false;
26420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26421         LDKCVec_ChannelDetailsZ ignored_channels_constr;
26422         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
26423         if (ignored_channels_constr.datalen > 0)
26424                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
26425         else
26426                 ignored_channels_constr.data = NULL;
26427         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
26428         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
26429                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
26430                 LDKChannelDetails ignored_channels_conv_16_conv;
26431                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
26432                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
26433                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
26434                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
26435                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
26436         }
26437         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
26438         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
26439         int64_tArray ret_arr = NULL;
26440         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26441         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26442         for (size_t j = 0; j < ret_var.datalen; j++) {
26443                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26444                 *ret_conv_9_copy = ret_var.data[j];
26445                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
26446                 ret_arr_ptr[j] = ret_conv_9_ref;
26447         }
26448         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26449         FREE(ret_var.data);
26450         return ret_arr;
26451 }
26452
26453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
26454         LDKChainMonitor this_arg_conv;
26455         this_arg_conv.inner = (void*)(this_arg & (~1));
26456         this_arg_conv.is_owned = false;
26457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26458         LDKOutPoint funding_txo_conv;
26459         funding_txo_conv.inner = (void*)(funding_txo & (~1));
26460         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
26461         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
26462         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
26463         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
26464         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
26465         return (int64_t)ret_conv;
26466 }
26467
26468 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
26469         LDKChainMonitor this_arg_conv;
26470         this_arg_conv.inner = (void*)(this_arg & (~1));
26471         this_arg_conv.is_owned = false;
26472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26473         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
26474         int64_tArray ret_arr = NULL;
26475         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26476         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26477         for (size_t k = 0; k < ret_var.datalen; k++) {
26478                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
26479                 int64_t ret_conv_10_ref = 0;
26480                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26481                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26482                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
26483                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
26484                 if (ret_conv_10_var.is_owned) {
26485                         ret_conv_10_ref |= 1;
26486                 }
26487                 ret_arr_ptr[k] = ret_conv_10_ref;
26488         }
26489         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26490         FREE(ret_var.data);
26491         return ret_arr;
26492 }
26493
26494 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) {
26495         LDKChainMonitor this_arg_conv;
26496         this_arg_conv.inner = (void*)(this_arg & (~1));
26497         this_arg_conv.is_owned = false;
26498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26499         LDKOutPoint funding_txo_conv;
26500         funding_txo_conv.inner = (void*)(funding_txo & (~1));
26501         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
26502         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
26503         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
26504         LDKMonitorUpdateId completed_update_id_conv;
26505         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
26506         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
26507         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
26508         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
26509         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26510         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
26511         return (int64_t)ret_conv;
26512 }
26513
26514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
26515         LDKChainMonitor this_arg_conv;
26516         this_arg_conv.inner = (void*)(this_arg & (~1));
26517         this_arg_conv.is_owned = false;
26518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26519         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
26520         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
26521         return (int64_t)ret_ret;
26522 }
26523
26524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
26525         LDKChainMonitor this_arg_conv;
26526         this_arg_conv.inner = (void*)(this_arg & (~1));
26527         this_arg_conv.is_owned = false;
26528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26529         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
26530         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
26531         return (int64_t)ret_ret;
26532 }
26533
26534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
26535         LDKChainMonitor this_arg_conv;
26536         this_arg_conv.inner = (void*)(this_arg & (~1));
26537         this_arg_conv.is_owned = false;
26538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26539         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
26540         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
26541         return (int64_t)ret_ret;
26542 }
26543
26544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
26545         LDKChainMonitor this_arg_conv;
26546         this_arg_conv.inner = (void*)(this_arg & (~1));
26547         this_arg_conv.is_owned = false;
26548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26549         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
26550         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
26551         return (int64_t)ret_ret;
26552 }
26553
26554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26555         LDKChannelMonitorUpdate this_obj_conv;
26556         this_obj_conv.inner = (void*)(this_obj & (~1));
26557         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26559         ChannelMonitorUpdate_free(this_obj_conv);
26560 }
26561
26562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26563         LDKChannelMonitorUpdate this_ptr_conv;
26564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26565         this_ptr_conv.is_owned = false;
26566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26567         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
26568         return ret_conv;
26569 }
26570
26571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26572         LDKChannelMonitorUpdate this_ptr_conv;
26573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26574         this_ptr_conv.is_owned = false;
26575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26576         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
26577 }
26578
26579 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
26580         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
26581 int64_t ret_ref = 0;
26582 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26583 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26584 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26585 ret_ref = (uintptr_t)ret_var.inner;
26586 if (ret_var.is_owned) {
26587         ret_ref |= 1;
26588 }
26589         return ret_ref;
26590 }
26591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26592         LDKChannelMonitorUpdate arg_conv;
26593         arg_conv.inner = (void*)(arg & (~1));
26594         arg_conv.is_owned = false;
26595         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26596         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
26597         return ret_conv;
26598 }
26599
26600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26601         LDKChannelMonitorUpdate orig_conv;
26602         orig_conv.inner = (void*)(orig & (~1));
26603         orig_conv.is_owned = false;
26604         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26605         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
26606         int64_t ret_ref = 0;
26607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26610         ret_ref = (uintptr_t)ret_var.inner;
26611         if (ret_var.is_owned) {
26612                 ret_ref |= 1;
26613         }
26614         return ret_ref;
26615 }
26616
26617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
26618         LDKChannelMonitorUpdate obj_conv;
26619         obj_conv.inner = (void*)(obj & (~1));
26620         obj_conv.is_owned = false;
26621         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26622         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
26623         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26624         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26625         CVec_u8Z_free(ret_var);
26626         return ret_arr;
26627 }
26628
26629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26630         LDKu8slice ser_ref;
26631         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26632         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26633         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
26634         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
26635         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26636         return (int64_t)ret_conv;
26637 }
26638
26639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26640         if ((this_ptr & 1) != 0) return;
26641         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26642         CHECK_ACCESS(this_ptr_ptr);
26643         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
26644         FREE((void*)this_ptr);
26645         MonitorEvent_free(this_ptr_conv);
26646 }
26647
26648 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
26649         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26650         *ret_copy = MonitorEvent_clone(arg);
26651 int64_t ret_ref = (uintptr_t)ret_copy;
26652         return ret_ref;
26653 }
26654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26655         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
26656         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
26657         return ret_conv;
26658 }
26659
26660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26661         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
26662         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26663         *ret_copy = MonitorEvent_clone(orig_conv);
26664         int64_t ret_ref = (uintptr_t)ret_copy;
26665         return ret_ref;
26666 }
26667
26668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
26669         LDKHTLCUpdate a_conv;
26670         a_conv.inner = (void*)(a & (~1));
26671         a_conv.is_owned = (a & 1) || (a == 0);
26672         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26673         a_conv = HTLCUpdate_clone(&a_conv);
26674         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26675         *ret_copy = MonitorEvent_htlcevent(a_conv);
26676         int64_t ret_ref = (uintptr_t)ret_copy;
26677         return ret_ref;
26678 }
26679
26680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
26681         LDKOutPoint a_conv;
26682         a_conv.inner = (void*)(a & (~1));
26683         a_conv.is_owned = (a & 1) || (a == 0);
26684         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26685         a_conv = OutPoint_clone(&a_conv);
26686         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26687         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
26688         int64_t ret_ref = (uintptr_t)ret_copy;
26689         return ret_ref;
26690 }
26691
26692 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) {
26693         LDKOutPoint funding_txo_conv;
26694         funding_txo_conv.inner = (void*)(funding_txo & (~1));
26695         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
26696         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
26697         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
26698         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26699         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
26700         int64_t ret_ref = (uintptr_t)ret_copy;
26701         return ret_ref;
26702 }
26703
26704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
26705         LDKOutPoint a_conv;
26706         a_conv.inner = (void*)(a & (~1));
26707         a_conv.is_owned = (a & 1) || (a == 0);
26708         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26709         a_conv = OutPoint_clone(&a_conv);
26710         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26711         *ret_copy = MonitorEvent_update_failed(a_conv);
26712         int64_t ret_ref = (uintptr_t)ret_copy;
26713         return ret_ref;
26714 }
26715
26716 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
26717         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
26718         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
26719         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26720         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26721         CVec_u8Z_free(ret_var);
26722         return ret_arr;
26723 }
26724
26725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26726         LDKu8slice ser_ref;
26727         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26728         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26729         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
26730         *ret_conv = MonitorEvent_read(ser_ref);
26731         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26732         return (int64_t)ret_conv;
26733 }
26734
26735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26736         LDKHTLCUpdate this_obj_conv;
26737         this_obj_conv.inner = (void*)(this_obj & (~1));
26738         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26740         HTLCUpdate_free(this_obj_conv);
26741 }
26742
26743 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
26744         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
26745 int64_t ret_ref = 0;
26746 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26747 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26748 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26749 ret_ref = (uintptr_t)ret_var.inner;
26750 if (ret_var.is_owned) {
26751         ret_ref |= 1;
26752 }
26753         return ret_ref;
26754 }
26755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26756         LDKHTLCUpdate arg_conv;
26757         arg_conv.inner = (void*)(arg & (~1));
26758         arg_conv.is_owned = false;
26759         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26760         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
26761         return ret_conv;
26762 }
26763
26764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26765         LDKHTLCUpdate orig_conv;
26766         orig_conv.inner = (void*)(orig & (~1));
26767         orig_conv.is_owned = false;
26768         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26769         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
26770         int64_t ret_ref = 0;
26771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26774         ret_ref = (uintptr_t)ret_var.inner;
26775         if (ret_var.is_owned) {
26776                 ret_ref |= 1;
26777         }
26778         return ret_ref;
26779 }
26780
26781 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
26782         LDKHTLCUpdate obj_conv;
26783         obj_conv.inner = (void*)(obj & (~1));
26784         obj_conv.is_owned = false;
26785         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26786         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
26787         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26788         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26789         CVec_u8Z_free(ret_var);
26790         return ret_arr;
26791 }
26792
26793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26794         LDKu8slice ser_ref;
26795         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26796         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26797         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
26798         *ret_conv = HTLCUpdate_read(ser_ref);
26799         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26800         return (int64_t)ret_conv;
26801 }
26802
26803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26804         if ((this_ptr & 1) != 0) return;
26805         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
26806         CHECK_ACCESS(this_ptr_ptr);
26807         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
26808         FREE((void*)this_ptr);
26809         Balance_free(this_ptr_conv);
26810 }
26811
26812 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
26813         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26814         *ret_copy = Balance_clone(arg);
26815 int64_t ret_ref = (uintptr_t)ret_copy;
26816         return ret_ref;
26817 }
26818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26819         LDKBalance* arg_conv = (LDKBalance*)arg;
26820         int64_t ret_conv = Balance_clone_ptr(arg_conv);
26821         return ret_conv;
26822 }
26823
26824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26825         LDKBalance* orig_conv = (LDKBalance*)orig;
26826         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26827         *ret_copy = Balance_clone(orig_conv);
26828         int64_t ret_ref = (uintptr_t)ret_copy;
26829         return ret_ref;
26830 }
26831
26832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
26833         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26834         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
26835         int64_t ret_ref = (uintptr_t)ret_copy;
26836         return ret_ref;
26837 }
26838
26839 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) {
26840         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26841         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
26842         int64_t ret_ref = (uintptr_t)ret_copy;
26843         return ret_ref;
26844 }
26845
26846 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) {
26847         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26848         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
26849         int64_t ret_ref = (uintptr_t)ret_copy;
26850         return ret_ref;
26851 }
26852
26853 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) {
26854         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26855         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
26856         int64_t ret_ref = (uintptr_t)ret_copy;
26857         return ret_ref;
26858 }
26859
26860 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26861         LDKBalance* a_conv = (LDKBalance*)a;
26862         LDKBalance* b_conv = (LDKBalance*)b;
26863         jboolean ret_conv = Balance_eq(a_conv, b_conv);
26864         return ret_conv;
26865 }
26866
26867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26868         LDKChannelMonitor this_obj_conv;
26869         this_obj_conv.inner = (void*)(this_obj & (~1));
26870         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26872         ChannelMonitor_free(this_obj_conv);
26873 }
26874
26875 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
26876         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
26877 int64_t ret_ref = 0;
26878 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26879 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26880 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26881 ret_ref = (uintptr_t)ret_var.inner;
26882 if (ret_var.is_owned) {
26883         ret_ref |= 1;
26884 }
26885         return ret_ref;
26886 }
26887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26888         LDKChannelMonitor arg_conv;
26889         arg_conv.inner = (void*)(arg & (~1));
26890         arg_conv.is_owned = false;
26891         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26892         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
26893         return ret_conv;
26894 }
26895
26896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26897         LDKChannelMonitor orig_conv;
26898         orig_conv.inner = (void*)(orig & (~1));
26899         orig_conv.is_owned = false;
26900         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26901         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
26902         int64_t ret_ref = 0;
26903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26906         ret_ref = (uintptr_t)ret_var.inner;
26907         if (ret_var.is_owned) {
26908                 ret_ref |= 1;
26909         }
26910         return ret_ref;
26911 }
26912
26913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26914         LDKChannelMonitor obj_conv;
26915         obj_conv.inner = (void*)(obj & (~1));
26916         obj_conv.is_owned = false;
26917         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26918         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
26919         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26920         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26921         CVec_u8Z_free(ret_var);
26922         return ret_arr;
26923 }
26924
26925 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) {
26926         LDKChannelMonitor this_arg_conv;
26927         this_arg_conv.inner = (void*)(this_arg & (~1));
26928         this_arg_conv.is_owned = false;
26929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26930         LDKChannelMonitorUpdate updates_conv;
26931         updates_conv.inner = (void*)(updates & (~1));
26932         updates_conv.is_owned = false;
26933         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
26934         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26935         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
26936         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
26937         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26938         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
26939         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
26940         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26941         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
26942         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26943         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
26944         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
26945         return (int64_t)ret_conv;
26946 }
26947
26948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26949         LDKChannelMonitor this_arg_conv;
26950         this_arg_conv.inner = (void*)(this_arg & (~1));
26951         this_arg_conv.is_owned = false;
26952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26953         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
26954         return ret_conv;
26955 }
26956
26957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
26958         LDKChannelMonitor this_arg_conv;
26959         this_arg_conv.inner = (void*)(this_arg & (~1));
26960         this_arg_conv.is_owned = false;
26961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26962         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
26963         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
26964         return ((int64_t)ret_conv);
26965 }
26966
26967 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
26968         LDKChannelMonitor this_arg_conv;
26969         this_arg_conv.inner = (void*)(this_arg & (~1));
26970         this_arg_conv.is_owned = false;
26971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26972         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
26973         int64_tArray ret_arr = NULL;
26974         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26975         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26976         for (size_t o = 0; o < ret_var.datalen; o++) {
26977                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
26978                 *ret_conv_40_conv = ret_var.data[o];
26979                 ret_arr_ptr[o] = ((int64_t)ret_conv_40_conv);
26980         }
26981         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26982         FREE(ret_var.data);
26983         return ret_arr;
26984 }
26985
26986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
26987         LDKChannelMonitor this_arg_conv;
26988         this_arg_conv.inner = (void*)(this_arg & (~1));
26989         this_arg_conv.is_owned = false;
26990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26991         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
26992         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
26993         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
26994         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
26995 }
26996
26997 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
26998         LDKChannelMonitor this_arg_conv;
26999         this_arg_conv.inner = (void*)(this_arg & (~1));
27000         this_arg_conv.is_owned = false;
27001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27002         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
27003         int64_tArray ret_arr = NULL;
27004         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27005         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27006         for (size_t o = 0; o < ret_var.datalen; o++) {
27007                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27008                 *ret_conv_14_copy = ret_var.data[o];
27009                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
27010                 ret_arr_ptr[o] = ret_conv_14_ref;
27011         }
27012         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27013         FREE(ret_var.data);
27014         return ret_arr;
27015 }
27016
27017 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
27018         LDKChannelMonitor this_arg_conv;
27019         this_arg_conv.inner = (void*)(this_arg & (~1));
27020         this_arg_conv.is_owned = false;
27021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27022         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
27023         int64_tArray ret_arr = NULL;
27024         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27025         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27026         for (size_t h = 0; h < ret_var.datalen; h++) {
27027                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
27028                 *ret_conv_7_copy = ret_var.data[h];
27029                 int64_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
27030                 ret_arr_ptr[h] = ret_conv_7_ref;
27031         }
27032         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27033         FREE(ret_var.data);
27034         return ret_arr;
27035 }
27036
27037 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) {
27038         LDKChannelMonitor this_arg_conv;
27039         this_arg_conv.inner = (void*)(this_arg & (~1));
27040         this_arg_conv.is_owned = false;
27041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27042         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27043         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
27044         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
27045         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
27046         jobjectArray ret_arr = NULL;
27047         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27048         ;
27049         for (size_t i = 0; i < ret_var.datalen; i++) {
27050                 LDKTransaction ret_conv_8_var = ret_var.data[i];
27051                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
27052                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
27053                 Transaction_free(ret_conv_8_var);
27054                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27055         }
27056         
27057         FREE(ret_var.data);
27058         return ret_arr;
27059 }
27060
27061 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) {
27062         LDKChannelMonitor this_arg_conv;
27063         this_arg_conv.inner = (void*)(this_arg & (~1));
27064         this_arg_conv.is_owned = false;
27065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27066         unsigned char header_arr[80];
27067         CHECK((*env)->GetArrayLength(env, header) == 80);
27068         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27069         unsigned char (*header_ref)[80] = &header_arr;
27070         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
27071         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
27072         if (txdata_constr.datalen > 0)
27073                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
27074         else
27075                 txdata_constr.data = NULL;
27076         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
27077         for (size_t c = 0; c < txdata_constr.datalen; c++) {
27078                 int64_t txdata_conv_28 = txdata_vals[c];
27079                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
27080                 CHECK_ACCESS(txdata_conv_28_ptr);
27081                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
27082                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
27083                 txdata_constr.data[c] = txdata_conv_28_conv;
27084         }
27085         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
27086         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27087         CHECK_ACCESS(broadcaster_ptr);
27088         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27089         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27090                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27091                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27092         }
27093         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27094         CHECK_ACCESS(fee_estimator_ptr);
27095         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27096         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27097                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27098                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27099         }
27100         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27101         CHECK_ACCESS(logger_ptr);
27102         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27103         if (logger_conv.free == LDKLogger_JCalls_free) {
27104                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27105                 LDKLogger_JCalls_cloned(&logger_conv);
27106         }
27107         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);
27108         int64_tArray ret_arr = NULL;
27109         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27110         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27111         for (size_t n = 0; n < ret_var.datalen; n++) {
27112                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27113                 *ret_conv_39_conv = ret_var.data[n];
27114                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27115         }
27116         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27117         FREE(ret_var.data);
27118         return ret_arr;
27119 }
27120
27121 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) {
27122         LDKChannelMonitor this_arg_conv;
27123         this_arg_conv.inner = (void*)(this_arg & (~1));
27124         this_arg_conv.is_owned = false;
27125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27126         unsigned char header_arr[80];
27127         CHECK((*env)->GetArrayLength(env, header) == 80);
27128         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27129         unsigned char (*header_ref)[80] = &header_arr;
27130         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27131         CHECK_ACCESS(broadcaster_ptr);
27132         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27133         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27134                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27135                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27136         }
27137         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27138         CHECK_ACCESS(fee_estimator_ptr);
27139         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27140         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27141                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27142                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27143         }
27144         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27145         CHECK_ACCESS(logger_ptr);
27146         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27147         if (logger_conv.free == LDKLogger_JCalls_free) {
27148                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27149                 LDKLogger_JCalls_cloned(&logger_conv);
27150         }
27151         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
27152 }
27153
27154 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) {
27155         LDKChannelMonitor this_arg_conv;
27156         this_arg_conv.inner = (void*)(this_arg & (~1));
27157         this_arg_conv.is_owned = false;
27158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27159         unsigned char header_arr[80];
27160         CHECK((*env)->GetArrayLength(env, header) == 80);
27161         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27162         unsigned char (*header_ref)[80] = &header_arr;
27163         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
27164         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
27165         if (txdata_constr.datalen > 0)
27166                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
27167         else
27168                 txdata_constr.data = NULL;
27169         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
27170         for (size_t c = 0; c < txdata_constr.datalen; c++) {
27171                 int64_t txdata_conv_28 = txdata_vals[c];
27172                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
27173                 CHECK_ACCESS(txdata_conv_28_ptr);
27174                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
27175                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
27176                 txdata_constr.data[c] = txdata_conv_28_conv;
27177         }
27178         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
27179         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27180         CHECK_ACCESS(broadcaster_ptr);
27181         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27182         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27183                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27184                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27185         }
27186         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27187         CHECK_ACCESS(fee_estimator_ptr);
27188         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27189         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27190                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27191                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27192         }
27193         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27194         CHECK_ACCESS(logger_ptr);
27195         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27196         if (logger_conv.free == LDKLogger_JCalls_free) {
27197                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27198                 LDKLogger_JCalls_cloned(&logger_conv);
27199         }
27200         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);
27201         int64_tArray ret_arr = NULL;
27202         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27203         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27204         for (size_t n = 0; n < ret_var.datalen; n++) {
27205                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27206                 *ret_conv_39_conv = ret_var.data[n];
27207                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27208         }
27209         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27210         FREE(ret_var.data);
27211         return ret_arr;
27212 }
27213
27214 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) {
27215         LDKChannelMonitor this_arg_conv;
27216         this_arg_conv.inner = (void*)(this_arg & (~1));
27217         this_arg_conv.is_owned = false;
27218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27219         unsigned char txid_arr[32];
27220         CHECK((*env)->GetArrayLength(env, txid) == 32);
27221         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
27222         unsigned char (*txid_ref)[32] = &txid_arr;
27223         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27224         CHECK_ACCESS(broadcaster_ptr);
27225         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27226         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27227                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27228                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27229         }
27230         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27231         CHECK_ACCESS(fee_estimator_ptr);
27232         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27233         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27234                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27235                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27236         }
27237         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27238         CHECK_ACCESS(logger_ptr);
27239         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27240         if (logger_conv.free == LDKLogger_JCalls_free) {
27241                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27242                 LDKLogger_JCalls_cloned(&logger_conv);
27243         }
27244         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
27245 }
27246
27247 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) {
27248         LDKChannelMonitor this_arg_conv;
27249         this_arg_conv.inner = (void*)(this_arg & (~1));
27250         this_arg_conv.is_owned = false;
27251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27252         unsigned char header_arr[80];
27253         CHECK((*env)->GetArrayLength(env, header) == 80);
27254         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
27255         unsigned char (*header_ref)[80] = &header_arr;
27256         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
27257         CHECK_ACCESS(broadcaster_ptr);
27258         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27259         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27260                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27261                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27262         }
27263         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
27264         CHECK_ACCESS(fee_estimator_ptr);
27265         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
27266         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
27267                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27268                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
27269         }
27270         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
27271         CHECK_ACCESS(logger_ptr);
27272         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27273         if (logger_conv.free == LDKLogger_JCalls_free) {
27274                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27275                 LDKLogger_JCalls_cloned(&logger_conv);
27276         }
27277         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
27278         int64_tArray ret_arr = NULL;
27279         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27280         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27281         for (size_t n = 0; n < ret_var.datalen; n++) {
27282                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
27283                 *ret_conv_39_conv = ret_var.data[n];
27284                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
27285         }
27286         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27287         FREE(ret_var.data);
27288         return ret_arr;
27289 }
27290
27291 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
27292         LDKChannelMonitor this_arg_conv;
27293         this_arg_conv.inner = (void*)(this_arg & (~1));
27294         this_arg_conv.is_owned = false;
27295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27296         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
27297         jobjectArray ret_arr = NULL;
27298         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
27299         ;
27300         for (size_t i = 0; i < ret_var.datalen; i++) {
27301                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
27302                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
27303                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
27304         }
27305         
27306         FREE(ret_var.data);
27307         return ret_arr;
27308 }
27309
27310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
27311         LDKChannelMonitor this_arg_conv;
27312         this_arg_conv.inner = (void*)(this_arg & (~1));
27313         this_arg_conv.is_owned = false;
27314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27315         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
27316         int64_t ret_ref = 0;
27317         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27318         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27320         ret_ref = (uintptr_t)ret_var.inner;
27321         if (ret_var.is_owned) {
27322                 ret_ref |= 1;
27323         }
27324         return ret_ref;
27325 }
27326
27327 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
27328         LDKChannelMonitor this_arg_conv;
27329         this_arg_conv.inner = (void*)(this_arg & (~1));
27330         this_arg_conv.is_owned = false;
27331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27332         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
27333         int64_tArray ret_arr = NULL;
27334         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27335         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27336         for (size_t j = 0; j < ret_var.datalen; j++) {
27337                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27338                 *ret_conv_9_copy = ret_var.data[j];
27339                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
27340                 ret_arr_ptr[j] = ret_conv_9_ref;
27341         }
27342         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27343         FREE(ret_var.data);
27344         return ret_arr;
27345 }
27346
27347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
27348         LDKu8slice ser_ref;
27349         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27350         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27351         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
27352         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
27353         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
27354         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
27355         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
27356         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27357         return (int64_t)ret_conv;
27358 }
27359
27360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27361         LDKOutPoint this_obj_conv;
27362         this_obj_conv.inner = (void*)(this_obj & (~1));
27363         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27365         OutPoint_free(this_obj_conv);
27366 }
27367
27368 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
27369         LDKOutPoint this_ptr_conv;
27370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27371         this_ptr_conv.is_owned = false;
27372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27373         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27374         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
27375         return ret_arr;
27376 }
27377
27378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27379         LDKOutPoint this_ptr_conv;
27380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27381         this_ptr_conv.is_owned = false;
27382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27383         LDKThirtyTwoBytes val_ref;
27384         CHECK((*env)->GetArrayLength(env, val) == 32);
27385         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27386         OutPoint_set_txid(&this_ptr_conv, val_ref);
27387 }
27388
27389 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
27390         LDKOutPoint this_ptr_conv;
27391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27392         this_ptr_conv.is_owned = false;
27393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27394         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
27395         return ret_conv;
27396 }
27397
27398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27399         LDKOutPoint this_ptr_conv;
27400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27401         this_ptr_conv.is_owned = false;
27402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27403         OutPoint_set_index(&this_ptr_conv, val);
27404 }
27405
27406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
27407         LDKThirtyTwoBytes txid_arg_ref;
27408         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
27409         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
27410         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
27411         int64_t ret_ref = 0;
27412         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27413         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27415         ret_ref = (uintptr_t)ret_var.inner;
27416         if (ret_var.is_owned) {
27417                 ret_ref |= 1;
27418         }
27419         return ret_ref;
27420 }
27421
27422 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
27423         LDKOutPoint ret_var = OutPoint_clone(arg);
27424 int64_t ret_ref = 0;
27425 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27426 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27427 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27428 ret_ref = (uintptr_t)ret_var.inner;
27429 if (ret_var.is_owned) {
27430         ret_ref |= 1;
27431 }
27432         return ret_ref;
27433 }
27434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27435         LDKOutPoint arg_conv;
27436         arg_conv.inner = (void*)(arg & (~1));
27437         arg_conv.is_owned = false;
27438         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27439         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
27440         return ret_conv;
27441 }
27442
27443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27444         LDKOutPoint orig_conv;
27445         orig_conv.inner = (void*)(orig & (~1));
27446         orig_conv.is_owned = false;
27447         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27448         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
27449         int64_t ret_ref = 0;
27450         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27451         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27453         ret_ref = (uintptr_t)ret_var.inner;
27454         if (ret_var.is_owned) {
27455                 ret_ref |= 1;
27456         }
27457         return ret_ref;
27458 }
27459
27460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27461         LDKOutPoint a_conv;
27462         a_conv.inner = (void*)(a & (~1));
27463         a_conv.is_owned = false;
27464         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27465         LDKOutPoint b_conv;
27466         b_conv.inner = (void*)(b & (~1));
27467         b_conv.is_owned = false;
27468         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27469         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
27470         return ret_conv;
27471 }
27472
27473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
27474         LDKOutPoint o_conv;
27475         o_conv.inner = (void*)(o & (~1));
27476         o_conv.is_owned = false;
27477         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27478         int64_t ret_conv = OutPoint_hash(&o_conv);
27479         return ret_conv;
27480 }
27481
27482 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
27483         LDKOutPoint this_arg_conv;
27484         this_arg_conv.inner = (void*)(this_arg & (~1));
27485         this_arg_conv.is_owned = false;
27486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27487         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27488         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
27489         return ret_arr;
27490 }
27491
27492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
27493         LDKOutPoint obj_conv;
27494         obj_conv.inner = (void*)(obj & (~1));
27495         obj_conv.is_owned = false;
27496         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27497         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
27498         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27499         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27500         CVec_u8Z_free(ret_var);
27501         return ret_arr;
27502 }
27503
27504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27505         LDKu8slice ser_ref;
27506         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27507         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27508         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
27509         *ret_conv = OutPoint_read(ser_ref);
27510         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27511         return (int64_t)ret_conv;
27512 }
27513
27514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27515         LDKDelayedPaymentOutputDescriptor this_obj_conv;
27516         this_obj_conv.inner = (void*)(this_obj & (~1));
27517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27519         DelayedPaymentOutputDescriptor_free(this_obj_conv);
27520 }
27521
27522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27523         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27525         this_ptr_conv.is_owned = false;
27526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27527         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
27528         int64_t ret_ref = 0;
27529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27532         ret_ref = (uintptr_t)ret_var.inner;
27533         if (ret_var.is_owned) {
27534                 ret_ref |= 1;
27535         }
27536         return ret_ref;
27537 }
27538
27539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27540         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27542         this_ptr_conv.is_owned = false;
27543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27544         LDKOutPoint val_conv;
27545         val_conv.inner = (void*)(val & (~1));
27546         val_conv.is_owned = (val & 1) || (val == 0);
27547         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27548         val_conv = OutPoint_clone(&val_conv);
27549         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
27550 }
27551
27552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27553         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27555         this_ptr_conv.is_owned = false;
27556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27557         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27558         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
27559         return ret_arr;
27560 }
27561
27562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27563         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27565         this_ptr_conv.is_owned = false;
27566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27567         LDKPublicKey val_ref;
27568         CHECK((*env)->GetArrayLength(env, val) == 33);
27569         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27570         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
27571 }
27572
27573 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27574         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27576         this_ptr_conv.is_owned = false;
27577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27578         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
27579         return ret_conv;
27580 }
27581
27582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27583         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27585         this_ptr_conv.is_owned = false;
27586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27587         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
27588 }
27589
27590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27591         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27593         this_ptr_conv.is_owned = false;
27594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27595         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27596         CHECK_ACCESS(val_ptr);
27597         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
27598         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
27599         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
27600 }
27601
27602 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27603         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27605         this_ptr_conv.is_owned = false;
27606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27607         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27608         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
27609         return ret_arr;
27610 }
27611
27612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27613         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27615         this_ptr_conv.is_owned = false;
27616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27617         LDKPublicKey val_ref;
27618         CHECK((*env)->GetArrayLength(env, val) == 33);
27619         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27620         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
27621 }
27622
27623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27624         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27626         this_ptr_conv.is_owned = false;
27627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27628         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27629         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
27630         return ret_arr;
27631 }
27632
27633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27634         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27636         this_ptr_conv.is_owned = false;
27637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27638         LDKThirtyTwoBytes val_ref;
27639         CHECK((*env)->GetArrayLength(env, val) == 32);
27640         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27641         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
27642 }
27643
27644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27645         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27647         this_ptr_conv.is_owned = false;
27648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27649         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
27650         return ret_conv;
27651 }
27652
27653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27654         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
27655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27656         this_ptr_conv.is_owned = false;
27657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27658         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
27659 }
27660
27661 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) {
27662         LDKOutPoint outpoint_arg_conv;
27663         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
27664         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
27665         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
27666         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
27667         LDKPublicKey per_commitment_point_arg_ref;
27668         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
27669         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
27670         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
27671         CHECK_ACCESS(output_arg_ptr);
27672         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
27673         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
27674         LDKPublicKey revocation_pubkey_arg_ref;
27675         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
27676         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
27677         LDKThirtyTwoBytes channel_keys_id_arg_ref;
27678         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
27679         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
27680         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);
27681         int64_t ret_ref = 0;
27682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27685         ret_ref = (uintptr_t)ret_var.inner;
27686         if (ret_var.is_owned) {
27687                 ret_ref |= 1;
27688         }
27689         return ret_ref;
27690 }
27691
27692 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
27693         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
27694 int64_t ret_ref = 0;
27695 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27696 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27697 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27698 ret_ref = (uintptr_t)ret_var.inner;
27699 if (ret_var.is_owned) {
27700         ret_ref |= 1;
27701 }
27702         return ret_ref;
27703 }
27704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27705         LDKDelayedPaymentOutputDescriptor arg_conv;
27706         arg_conv.inner = (void*)(arg & (~1));
27707         arg_conv.is_owned = false;
27708         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27709         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
27710         return ret_conv;
27711 }
27712
27713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27714         LDKDelayedPaymentOutputDescriptor orig_conv;
27715         orig_conv.inner = (void*)(orig & (~1));
27716         orig_conv.is_owned = false;
27717         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27718         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
27719         int64_t ret_ref = 0;
27720         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27721         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27723         ret_ref = (uintptr_t)ret_var.inner;
27724         if (ret_var.is_owned) {
27725                 ret_ref |= 1;
27726         }
27727         return ret_ref;
27728 }
27729
27730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27731         LDKDelayedPaymentOutputDescriptor obj_conv;
27732         obj_conv.inner = (void*)(obj & (~1));
27733         obj_conv.is_owned = false;
27734         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27735         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
27736         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27737         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27738         CVec_u8Z_free(ret_var);
27739         return ret_arr;
27740 }
27741
27742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27743         LDKu8slice ser_ref;
27744         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27745         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27746         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
27747         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
27748         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27749         return (int64_t)ret_conv;
27750 }
27751
27752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27753         LDKStaticPaymentOutputDescriptor this_obj_conv;
27754         this_obj_conv.inner = (void*)(this_obj & (~1));
27755         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27757         StaticPaymentOutputDescriptor_free(this_obj_conv);
27758 }
27759
27760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27761         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27763         this_ptr_conv.is_owned = false;
27764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27765         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
27766         int64_t ret_ref = 0;
27767         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27768         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27770         ret_ref = (uintptr_t)ret_var.inner;
27771         if (ret_var.is_owned) {
27772                 ret_ref |= 1;
27773         }
27774         return ret_ref;
27775 }
27776
27777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27778         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27780         this_ptr_conv.is_owned = false;
27781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27782         LDKOutPoint val_conv;
27783         val_conv.inner = (void*)(val & (~1));
27784         val_conv.is_owned = (val & 1) || (val == 0);
27785         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27786         val_conv = OutPoint_clone(&val_conv);
27787         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
27788 }
27789
27790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27791         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27793         this_ptr_conv.is_owned = false;
27794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27795         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27796         CHECK_ACCESS(val_ptr);
27797         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
27798         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
27799         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
27800 }
27801
27802 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27803         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27805         this_ptr_conv.is_owned = false;
27806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27807         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27808         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
27809         return ret_arr;
27810 }
27811
27812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27813         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27815         this_ptr_conv.is_owned = false;
27816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27817         LDKThirtyTwoBytes val_ref;
27818         CHECK((*env)->GetArrayLength(env, val) == 32);
27819         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27820         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
27821 }
27822
27823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27824         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27826         this_ptr_conv.is_owned = false;
27827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27828         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
27829         return ret_conv;
27830 }
27831
27832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27833         LDKStaticPaymentOutputDescriptor this_ptr_conv;
27834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27835         this_ptr_conv.is_owned = false;
27836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27837         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
27838 }
27839
27840 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) {
27841         LDKOutPoint outpoint_arg_conv;
27842         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
27843         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
27844         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
27845         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
27846         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
27847         CHECK_ACCESS(output_arg_ptr);
27848         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
27849         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
27850         LDKThirtyTwoBytes channel_keys_id_arg_ref;
27851         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
27852         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
27853         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
27854         int64_t ret_ref = 0;
27855         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27856         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27858         ret_ref = (uintptr_t)ret_var.inner;
27859         if (ret_var.is_owned) {
27860                 ret_ref |= 1;
27861         }
27862         return ret_ref;
27863 }
27864
27865 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
27866         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
27867 int64_t ret_ref = 0;
27868 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27869 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27870 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27871 ret_ref = (uintptr_t)ret_var.inner;
27872 if (ret_var.is_owned) {
27873         ret_ref |= 1;
27874 }
27875         return ret_ref;
27876 }
27877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27878         LDKStaticPaymentOutputDescriptor arg_conv;
27879         arg_conv.inner = (void*)(arg & (~1));
27880         arg_conv.is_owned = false;
27881         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27882         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
27883         return ret_conv;
27884 }
27885
27886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27887         LDKStaticPaymentOutputDescriptor orig_conv;
27888         orig_conv.inner = (void*)(orig & (~1));
27889         orig_conv.is_owned = false;
27890         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27891         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
27892         int64_t ret_ref = 0;
27893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27896         ret_ref = (uintptr_t)ret_var.inner;
27897         if (ret_var.is_owned) {
27898                 ret_ref |= 1;
27899         }
27900         return ret_ref;
27901 }
27902
27903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27904         LDKStaticPaymentOutputDescriptor obj_conv;
27905         obj_conv.inner = (void*)(obj & (~1));
27906         obj_conv.is_owned = false;
27907         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27908         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
27909         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27910         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27911         CVec_u8Z_free(ret_var);
27912         return ret_arr;
27913 }
27914
27915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27916         LDKu8slice ser_ref;
27917         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27918         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27919         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
27920         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
27921         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27922         return (int64_t)ret_conv;
27923 }
27924
27925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27926         if ((this_ptr & 1) != 0) return;
27927         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27928         CHECK_ACCESS(this_ptr_ptr);
27929         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
27930         FREE((void*)this_ptr);
27931         SpendableOutputDescriptor_free(this_ptr_conv);
27932 }
27933
27934 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
27935         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27936         *ret_copy = SpendableOutputDescriptor_clone(arg);
27937 int64_t ret_ref = (uintptr_t)ret_copy;
27938         return ret_ref;
27939 }
27940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27941         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
27942         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
27943         return ret_conv;
27944 }
27945
27946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27947         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
27948         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27949         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
27950         int64_t ret_ref = (uintptr_t)ret_copy;
27951         return ret_ref;
27952 }
27953
27954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
27955         LDKOutPoint outpoint_conv;
27956         outpoint_conv.inner = (void*)(outpoint & (~1));
27957         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
27958         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
27959         outpoint_conv = OutPoint_clone(&outpoint_conv);
27960         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
27961         CHECK_ACCESS(output_ptr);
27962         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
27963         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
27964         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27965         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
27966         int64_t ret_ref = (uintptr_t)ret_copy;
27967         return ret_ref;
27968 }
27969
27970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27971         LDKDelayedPaymentOutputDescriptor a_conv;
27972         a_conv.inner = (void*)(a & (~1));
27973         a_conv.is_owned = (a & 1) || (a == 0);
27974         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27975         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
27976         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27977         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
27978         int64_t ret_ref = (uintptr_t)ret_copy;
27979         return ret_ref;
27980 }
27981
27982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27983         LDKStaticPaymentOutputDescriptor a_conv;
27984         a_conv.inner = (void*)(a & (~1));
27985         a_conv.is_owned = (a & 1) || (a == 0);
27986         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27987         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
27988         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27989         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
27990         int64_t ret_ref = (uintptr_t)ret_copy;
27991         return ret_ref;
27992 }
27993
27994 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27995         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
27996         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
27997         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27998         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27999         CVec_u8Z_free(ret_var);
28000         return ret_arr;
28001 }
28002
28003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28004         LDKu8slice ser_ref;
28005         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28006         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28007         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
28008         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
28009         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28010         return (int64_t)ret_conv;
28011 }
28012
28013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28014         if ((this_ptr & 1) != 0) return;
28015         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28016         CHECK_ACCESS(this_ptr_ptr);
28017         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
28018         FREE((void*)this_ptr);
28019         BaseSign_free(this_ptr_conv);
28020 }
28021
28022 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
28023         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28024         *ret_ret = Sign_clone(arg);
28025         return (int64_t)ret_ret;
28026 }
28027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28028         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
28029         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28030         LDKSign* arg_conv = (LDKSign*)arg_ptr;
28031         int64_t ret_conv = Sign_clone_ptr(arg_conv);
28032         return ret_conv;
28033 }
28034
28035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28036         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
28037         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
28038         LDKSign* orig_conv = (LDKSign*)orig_ptr;
28039         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28040         *ret_ret = Sign_clone(orig_conv);
28041         return (int64_t)ret_ret;
28042 }
28043
28044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28045         if ((this_ptr & 1) != 0) return;
28046         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28047         CHECK_ACCESS(this_ptr_ptr);
28048         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
28049         FREE((void*)this_ptr);
28050         Sign_free(this_ptr_conv);
28051 }
28052
28053 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28054         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
28055         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
28056         return ret_conv;
28057 }
28058
28059 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
28060         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
28061         return ret_conv;
28062 }
28063
28064 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
28065         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
28066         return ret_conv;
28067 }
28068
28069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28070         if ((this_ptr & 1) != 0) return;
28071         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28072         CHECK_ACCESS(this_ptr_ptr);
28073         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
28074         FREE((void*)this_ptr);
28075         KeysInterface_free(this_ptr_conv);
28076 }
28077
28078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28079         LDKInMemorySigner this_obj_conv;
28080         this_obj_conv.inner = (void*)(this_obj & (~1));
28081         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28083         InMemorySigner_free(this_obj_conv);
28084 }
28085
28086 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28087         LDKInMemorySigner this_ptr_conv;
28088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28089         this_ptr_conv.is_owned = false;
28090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28091         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28092         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
28093         return ret_arr;
28094 }
28095
28096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28097         LDKInMemorySigner this_ptr_conv;
28098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28099         this_ptr_conv.is_owned = false;
28100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28101         LDKSecretKey val_ref;
28102         CHECK((*env)->GetArrayLength(env, val) == 32);
28103         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28104         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
28105 }
28106
28107 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28108         LDKInMemorySigner this_ptr_conv;
28109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28110         this_ptr_conv.is_owned = false;
28111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28112         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28113         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
28114         return ret_arr;
28115 }
28116
28117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28118         LDKInMemorySigner this_ptr_conv;
28119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28120         this_ptr_conv.is_owned = false;
28121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28122         LDKSecretKey val_ref;
28123         CHECK((*env)->GetArrayLength(env, val) == 32);
28124         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28125         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
28126 }
28127
28128 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28129         LDKInMemorySigner this_ptr_conv;
28130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28131         this_ptr_conv.is_owned = false;
28132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28133         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28134         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
28135         return ret_arr;
28136 }
28137
28138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28139         LDKInMemorySigner this_ptr_conv;
28140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28141         this_ptr_conv.is_owned = false;
28142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28143         LDKSecretKey val_ref;
28144         CHECK((*env)->GetArrayLength(env, val) == 32);
28145         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28146         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
28147 }
28148
28149 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28150         LDKInMemorySigner this_ptr_conv;
28151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28152         this_ptr_conv.is_owned = false;
28153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28154         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28155         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
28156         return ret_arr;
28157 }
28158
28159 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) {
28160         LDKInMemorySigner this_ptr_conv;
28161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28162         this_ptr_conv.is_owned = false;
28163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28164         LDKSecretKey val_ref;
28165         CHECK((*env)->GetArrayLength(env, val) == 32);
28166         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28167         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
28168 }
28169
28170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
28171         LDKInMemorySigner this_ptr_conv;
28172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28173         this_ptr_conv.is_owned = false;
28174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28175         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28176         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
28177         return ret_arr;
28178 }
28179
28180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28181         LDKInMemorySigner this_ptr_conv;
28182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28183         this_ptr_conv.is_owned = false;
28184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28185         LDKSecretKey val_ref;
28186         CHECK((*env)->GetArrayLength(env, val) == 32);
28187         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
28188         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
28189 }
28190
28191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
28192         LDKInMemorySigner this_ptr_conv;
28193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28194         this_ptr_conv.is_owned = false;
28195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28196         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28197         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
28198         return ret_arr;
28199 }
28200
28201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28202         LDKInMemorySigner this_ptr_conv;
28203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28204         this_ptr_conv.is_owned = false;
28205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28206         LDKThirtyTwoBytes val_ref;
28207         CHECK((*env)->GetArrayLength(env, val) == 32);
28208         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28209         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
28210 }
28211
28212 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
28213         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
28214 int64_t ret_ref = 0;
28215 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28216 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28217 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28218 ret_ref = (uintptr_t)ret_var.inner;
28219 if (ret_var.is_owned) {
28220         ret_ref |= 1;
28221 }
28222         return ret_ref;
28223 }
28224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28225         LDKInMemorySigner arg_conv;
28226         arg_conv.inner = (void*)(arg & (~1));
28227         arg_conv.is_owned = false;
28228         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28229         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
28230         return ret_conv;
28231 }
28232
28233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28234         LDKInMemorySigner orig_conv;
28235         orig_conv.inner = (void*)(orig & (~1));
28236         orig_conv.is_owned = false;
28237         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28238         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
28239         int64_t ret_ref = 0;
28240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28243         ret_ref = (uintptr_t)ret_var.inner;
28244         if (ret_var.is_owned) {
28245                 ret_ref |= 1;
28246         }
28247         return ret_ref;
28248 }
28249
28250 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) {
28251         LDKSecretKey node_secret_ref;
28252         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
28253         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
28254         LDKSecretKey funding_key_ref;
28255         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
28256         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
28257         LDKSecretKey revocation_base_key_ref;
28258         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
28259         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
28260         LDKSecretKey payment_key_ref;
28261         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
28262         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
28263         LDKSecretKey delayed_payment_base_key_ref;
28264         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
28265         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
28266         LDKSecretKey htlc_base_key_ref;
28267         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
28268         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
28269         LDKThirtyTwoBytes commitment_seed_ref;
28270         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
28271         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
28272         LDKThirtyTwoBytes channel_keys_id_ref;
28273         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
28274         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
28275         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);
28276         int64_t ret_ref = 0;
28277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28280         ret_ref = (uintptr_t)ret_var.inner;
28281         if (ret_var.is_owned) {
28282                 ret_ref |= 1;
28283         }
28284         return ret_ref;
28285 }
28286
28287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
28288         LDKInMemorySigner this_arg_conv;
28289         this_arg_conv.inner = (void*)(this_arg & (~1));
28290         this_arg_conv.is_owned = false;
28291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28292         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
28293         int64_t ret_ref = 0;
28294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28297         ret_ref = (uintptr_t)ret_var.inner;
28298         if (ret_var.is_owned) {
28299                 ret_ref |= 1;
28300         }
28301         return ret_ref;
28302 }
28303
28304 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28305         LDKInMemorySigner this_arg_conv;
28306         this_arg_conv.inner = (void*)(this_arg & (~1));
28307         this_arg_conv.is_owned = false;
28308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28309         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
28310         return ret_conv;
28311 }
28312
28313 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
28314         LDKInMemorySigner this_arg_conv;
28315         this_arg_conv.inner = (void*)(this_arg & (~1));
28316         this_arg_conv.is_owned = false;
28317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28318         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
28319         return ret_conv;
28320 }
28321
28322 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
28323         LDKInMemorySigner this_arg_conv;
28324         this_arg_conv.inner = (void*)(this_arg & (~1));
28325         this_arg_conv.is_owned = false;
28326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28327         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
28328         return ret_conv;
28329 }
28330
28331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
28332         LDKInMemorySigner this_arg_conv;
28333         this_arg_conv.inner = (void*)(this_arg & (~1));
28334         this_arg_conv.is_owned = false;
28335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28336         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
28337         int64_t ret_ref = 0;
28338         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28339         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28341         ret_ref = (uintptr_t)ret_var.inner;
28342         if (ret_var.is_owned) {
28343                 ret_ref |= 1;
28344         }
28345         return ret_ref;
28346 }
28347
28348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
28349         LDKInMemorySigner this_arg_conv;
28350         this_arg_conv.inner = (void*)(this_arg & (~1));
28351         this_arg_conv.is_owned = false;
28352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28353         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
28354         int64_t ret_ref = 0;
28355         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28356         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28358         ret_ref = (uintptr_t)ret_var.inner;
28359         if (ret_var.is_owned) {
28360                 ret_ref |= 1;
28361         }
28362         return ret_ref;
28363 }
28364
28365 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
28366         LDKInMemorySigner this_arg_conv;
28367         this_arg_conv.inner = (void*)(this_arg & (~1));
28368         this_arg_conv.is_owned = false;
28369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28370         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
28371         return ret_conv;
28372 }
28373
28374 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) {
28375         LDKInMemorySigner this_arg_conv;
28376         this_arg_conv.inner = (void*)(this_arg & (~1));
28377         this_arg_conv.is_owned = false;
28378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28379         LDKTransaction spend_tx_ref;
28380         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
28381         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
28382         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
28383         spend_tx_ref.data_is_owned = true;
28384         LDKStaticPaymentOutputDescriptor descriptor_conv;
28385         descriptor_conv.inner = (void*)(descriptor & (~1));
28386         descriptor_conv.is_owned = false;
28387         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
28388         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
28389         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
28390         return (int64_t)ret_conv;
28391 }
28392
28393 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) {
28394         LDKInMemorySigner this_arg_conv;
28395         this_arg_conv.inner = (void*)(this_arg & (~1));
28396         this_arg_conv.is_owned = false;
28397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28398         LDKTransaction spend_tx_ref;
28399         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
28400         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
28401         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
28402         spend_tx_ref.data_is_owned = true;
28403         LDKDelayedPaymentOutputDescriptor descriptor_conv;
28404         descriptor_conv.inner = (void*)(descriptor & (~1));
28405         descriptor_conv.is_owned = false;
28406         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
28407         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
28408         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
28409         return (int64_t)ret_conv;
28410 }
28411
28412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
28413         LDKInMemorySigner this_arg_conv;
28414         this_arg_conv.inner = (void*)(this_arg & (~1));
28415         this_arg_conv.is_owned = false;
28416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28417         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
28418         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
28419         return (int64_t)ret_ret;
28420 }
28421
28422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
28423         LDKInMemorySigner this_arg_conv;
28424         this_arg_conv.inner = (void*)(this_arg & (~1));
28425         this_arg_conv.is_owned = false;
28426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28427         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
28428         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
28429         return (int64_t)ret_ret;
28430 }
28431
28432 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
28433         LDKInMemorySigner obj_conv;
28434         obj_conv.inner = (void*)(obj & (~1));
28435         obj_conv.is_owned = false;
28436         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28437         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
28438         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28439         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28440         CVec_u8Z_free(ret_var);
28441         return ret_arr;
28442 }
28443
28444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
28445         LDKu8slice ser_ref;
28446         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28447         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28448         LDKSecretKey arg_ref;
28449         CHECK((*env)->GetArrayLength(env, arg) == 32);
28450         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
28451         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
28452         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
28453         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28454         return (int64_t)ret_conv;
28455 }
28456
28457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28458         LDKKeysManager this_obj_conv;
28459         this_obj_conv.inner = (void*)(this_obj & (~1));
28460         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28462         KeysManager_free(this_obj_conv);
28463 }
28464
28465 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) {
28466         unsigned char seed_arr[32];
28467         CHECK((*env)->GetArrayLength(env, seed) == 32);
28468         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
28469         unsigned char (*seed_ref)[32] = &seed_arr;
28470         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
28471         int64_t ret_ref = 0;
28472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28475         ret_ref = (uintptr_t)ret_var.inner;
28476         if (ret_var.is_owned) {
28477                 ret_ref |= 1;
28478         }
28479         return ret_ref;
28480 }
28481
28482 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) {
28483         LDKKeysManager this_arg_conv;
28484         this_arg_conv.inner = (void*)(this_arg & (~1));
28485         this_arg_conv.is_owned = false;
28486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28487         unsigned char params_arr[32];
28488         CHECK((*env)->GetArrayLength(env, params) == 32);
28489         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
28490         unsigned char (*params_ref)[32] = &params_arr;
28491         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
28492         int64_t ret_ref = 0;
28493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28496         ret_ref = (uintptr_t)ret_var.inner;
28497         if (ret_var.is_owned) {
28498                 ret_ref |= 1;
28499         }
28500         return ret_ref;
28501 }
28502
28503 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) {
28504         LDKKeysManager this_arg_conv;
28505         this_arg_conv.inner = (void*)(this_arg & (~1));
28506         this_arg_conv.is_owned = false;
28507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28508         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
28509         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
28510         if (descriptors_constr.datalen > 0)
28511                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
28512         else
28513                 descriptors_constr.data = NULL;
28514         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
28515         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
28516                 int64_t descriptors_conv_27 = descriptors_vals[b];
28517                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
28518                 CHECK_ACCESS(descriptors_conv_27_ptr);
28519                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
28520                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
28521                 descriptors_constr.data[b] = descriptors_conv_27_conv;
28522         }
28523         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
28524         LDKCVec_TxOutZ outputs_constr;
28525         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
28526         if (outputs_constr.datalen > 0)
28527                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
28528         else
28529                 outputs_constr.data = NULL;
28530         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
28531         for (size_t h = 0; h < outputs_constr.datalen; h++) {
28532                 int64_t outputs_conv_7 = outputs_vals[h];
28533                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
28534                 CHECK_ACCESS(outputs_conv_7_ptr);
28535                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
28536                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
28537                 outputs_constr.data[h] = outputs_conv_7_conv;
28538         }
28539         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
28540         LDKCVec_u8Z change_destination_script_ref;
28541         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
28542         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
28543         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
28544         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
28545         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
28546         return (int64_t)ret_conv;
28547 }
28548
28549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
28550         LDKKeysManager this_arg_conv;
28551         this_arg_conv.inner = (void*)(this_arg & (~1));
28552         this_arg_conv.is_owned = false;
28553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28554         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
28555         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
28556         return (int64_t)ret_ret;
28557 }
28558
28559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28560         LDKPhantomKeysManager this_obj_conv;
28561         this_obj_conv.inner = (void*)(this_obj & (~1));
28562         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28564         PhantomKeysManager_free(this_obj_conv);
28565 }
28566
28567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
28568         LDKPhantomKeysManager this_arg_conv;
28569         this_arg_conv.inner = (void*)(this_arg & (~1));
28570         this_arg_conv.is_owned = false;
28571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28572         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
28573         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
28574         return (int64_t)ret_ret;
28575 }
28576
28577 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) {
28578         unsigned char seed_arr[32];
28579         CHECK((*env)->GetArrayLength(env, seed) == 32);
28580         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
28581         unsigned char (*seed_ref)[32] = &seed_arr;
28582         unsigned char cross_node_seed_arr[32];
28583         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
28584         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
28585         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
28586         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
28587         int64_t ret_ref = 0;
28588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28591         ret_ref = (uintptr_t)ret_var.inner;
28592         if (ret_var.is_owned) {
28593                 ret_ref |= 1;
28594         }
28595         return ret_ref;
28596 }
28597
28598 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) {
28599         LDKPhantomKeysManager this_arg_conv;
28600         this_arg_conv.inner = (void*)(this_arg & (~1));
28601         this_arg_conv.is_owned = false;
28602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28603         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
28604         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
28605         if (descriptors_constr.datalen > 0)
28606                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
28607         else
28608                 descriptors_constr.data = NULL;
28609         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
28610         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
28611                 int64_t descriptors_conv_27 = descriptors_vals[b];
28612                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
28613                 CHECK_ACCESS(descriptors_conv_27_ptr);
28614                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
28615                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
28616                 descriptors_constr.data[b] = descriptors_conv_27_conv;
28617         }
28618         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
28619         LDKCVec_TxOutZ outputs_constr;
28620         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
28621         if (outputs_constr.datalen > 0)
28622                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
28623         else
28624                 outputs_constr.data = NULL;
28625         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
28626         for (size_t h = 0; h < outputs_constr.datalen; h++) {
28627                 int64_t outputs_conv_7 = outputs_vals[h];
28628                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
28629                 CHECK_ACCESS(outputs_conv_7_ptr);
28630                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
28631                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
28632                 outputs_constr.data[h] = outputs_conv_7_conv;
28633         }
28634         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
28635         LDKCVec_u8Z change_destination_script_ref;
28636         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
28637         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
28638         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
28639         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
28640         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
28641         return (int64_t)ret_conv;
28642 }
28643
28644 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) {
28645         LDKPhantomKeysManager this_arg_conv;
28646         this_arg_conv.inner = (void*)(this_arg & (~1));
28647         this_arg_conv.is_owned = false;
28648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28649         unsigned char params_arr[32];
28650         CHECK((*env)->GetArrayLength(env, params) == 32);
28651         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
28652         unsigned char (*params_ref)[32] = &params_arr;
28653         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
28654         int64_t ret_ref = 0;
28655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28658         ret_ref = (uintptr_t)ret_var.inner;
28659         if (ret_var.is_owned) {
28660                 ret_ref |= 1;
28661         }
28662         return ret_ref;
28663 }
28664
28665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28666         LDKChannelManager this_obj_conv;
28667         this_obj_conv.inner = (void*)(this_obj & (~1));
28668         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28670         ChannelManager_free(this_obj_conv);
28671 }
28672
28673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28674         LDKChainParameters this_obj_conv;
28675         this_obj_conv.inner = (void*)(this_obj & (~1));
28676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28678         ChainParameters_free(this_obj_conv);
28679 }
28680
28681 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
28682         LDKChainParameters this_ptr_conv;
28683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28684         this_ptr_conv.is_owned = false;
28685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28686         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
28687         return ret_conv;
28688 }
28689
28690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
28691         LDKChainParameters this_ptr_conv;
28692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28693         this_ptr_conv.is_owned = false;
28694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28695         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
28696         ChainParameters_set_network(&this_ptr_conv, val_conv);
28697 }
28698
28699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
28700         LDKChainParameters this_ptr_conv;
28701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28702         this_ptr_conv.is_owned = false;
28703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28704         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
28705         int64_t ret_ref = 0;
28706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28709         ret_ref = (uintptr_t)ret_var.inner;
28710         if (ret_var.is_owned) {
28711                 ret_ref |= 1;
28712         }
28713         return ret_ref;
28714 }
28715
28716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28717         LDKChainParameters this_ptr_conv;
28718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28719         this_ptr_conv.is_owned = false;
28720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28721         LDKBestBlock val_conv;
28722         val_conv.inner = (void*)(val & (~1));
28723         val_conv.is_owned = (val & 1) || (val == 0);
28724         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28725         val_conv = BestBlock_clone(&val_conv);
28726         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
28727 }
28728
28729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
28730         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
28731         LDKBestBlock best_block_arg_conv;
28732         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
28733         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
28734         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
28735         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
28736         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
28737         int64_t ret_ref = 0;
28738         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28739         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28741         ret_ref = (uintptr_t)ret_var.inner;
28742         if (ret_var.is_owned) {
28743                 ret_ref |= 1;
28744         }
28745         return ret_ref;
28746 }
28747
28748 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
28749         LDKChainParameters ret_var = ChainParameters_clone(arg);
28750 int64_t ret_ref = 0;
28751 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28752 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28753 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28754 ret_ref = (uintptr_t)ret_var.inner;
28755 if (ret_var.is_owned) {
28756         ret_ref |= 1;
28757 }
28758         return ret_ref;
28759 }
28760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28761         LDKChainParameters arg_conv;
28762         arg_conv.inner = (void*)(arg & (~1));
28763         arg_conv.is_owned = false;
28764         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28765         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
28766         return ret_conv;
28767 }
28768
28769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28770         LDKChainParameters orig_conv;
28771         orig_conv.inner = (void*)(orig & (~1));
28772         orig_conv.is_owned = false;
28773         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28774         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
28775         int64_t ret_ref = 0;
28776         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28777         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28779         ret_ref = (uintptr_t)ret_var.inner;
28780         if (ret_var.is_owned) {
28781                 ret_ref |= 1;
28782         }
28783         return ret_ref;
28784 }
28785
28786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28787         LDKCounterpartyForwardingInfo this_obj_conv;
28788         this_obj_conv.inner = (void*)(this_obj & (~1));
28789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28791         CounterpartyForwardingInfo_free(this_obj_conv);
28792 }
28793
28794 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28795         LDKCounterpartyForwardingInfo this_ptr_conv;
28796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28797         this_ptr_conv.is_owned = false;
28798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28799         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
28800         return ret_conv;
28801 }
28802
28803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28804         LDKCounterpartyForwardingInfo this_ptr_conv;
28805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28806         this_ptr_conv.is_owned = false;
28807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28808         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
28809 }
28810
28811 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28812         LDKCounterpartyForwardingInfo this_ptr_conv;
28813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28814         this_ptr_conv.is_owned = false;
28815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28816         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
28817         return ret_conv;
28818 }
28819
28820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28821         LDKCounterpartyForwardingInfo this_ptr_conv;
28822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28823         this_ptr_conv.is_owned = false;
28824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28825         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
28826 }
28827
28828 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28829         LDKCounterpartyForwardingInfo this_ptr_conv;
28830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28831         this_ptr_conv.is_owned = false;
28832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28833         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
28834         return ret_conv;
28835 }
28836
28837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28838         LDKCounterpartyForwardingInfo this_ptr_conv;
28839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28840         this_ptr_conv.is_owned = false;
28841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28842         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
28843 }
28844
28845 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) {
28846         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
28847         int64_t ret_ref = 0;
28848         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28849         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28851         ret_ref = (uintptr_t)ret_var.inner;
28852         if (ret_var.is_owned) {
28853                 ret_ref |= 1;
28854         }
28855         return ret_ref;
28856 }
28857
28858 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
28859         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
28860 int64_t ret_ref = 0;
28861 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28862 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28863 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28864 ret_ref = (uintptr_t)ret_var.inner;
28865 if (ret_var.is_owned) {
28866         ret_ref |= 1;
28867 }
28868         return ret_ref;
28869 }
28870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28871         LDKCounterpartyForwardingInfo arg_conv;
28872         arg_conv.inner = (void*)(arg & (~1));
28873         arg_conv.is_owned = false;
28874         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28875         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
28876         return ret_conv;
28877 }
28878
28879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28880         LDKCounterpartyForwardingInfo orig_conv;
28881         orig_conv.inner = (void*)(orig & (~1));
28882         orig_conv.is_owned = false;
28883         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28884         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
28885         int64_t ret_ref = 0;
28886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28889         ret_ref = (uintptr_t)ret_var.inner;
28890         if (ret_var.is_owned) {
28891                 ret_ref |= 1;
28892         }
28893         return ret_ref;
28894 }
28895
28896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28897         LDKChannelCounterparty this_obj_conv;
28898         this_obj_conv.inner = (void*)(this_obj & (~1));
28899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28901         ChannelCounterparty_free(this_obj_conv);
28902 }
28903
28904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28905         LDKChannelCounterparty this_ptr_conv;
28906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28907         this_ptr_conv.is_owned = false;
28908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28909         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28910         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
28911         return ret_arr;
28912 }
28913
28914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28915         LDKChannelCounterparty this_ptr_conv;
28916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28917         this_ptr_conv.is_owned = false;
28918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28919         LDKPublicKey val_ref;
28920         CHECK((*env)->GetArrayLength(env, val) == 33);
28921         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28922         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
28923 }
28924
28925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28926         LDKChannelCounterparty this_ptr_conv;
28927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28928         this_ptr_conv.is_owned = false;
28929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28930         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
28931         int64_t ret_ref = 0;
28932         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28933         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28935         ret_ref = (uintptr_t)ret_var.inner;
28936         if (ret_var.is_owned) {
28937                 ret_ref |= 1;
28938         }
28939         return ret_ref;
28940 }
28941
28942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28943         LDKChannelCounterparty this_ptr_conv;
28944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28945         this_ptr_conv.is_owned = false;
28946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28947         LDKInitFeatures val_conv;
28948         val_conv.inner = (void*)(val & (~1));
28949         val_conv.is_owned = (val & 1) || (val == 0);
28950         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28951         val_conv = InitFeatures_clone(&val_conv);
28952         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
28953 }
28954
28955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
28956         LDKChannelCounterparty this_ptr_conv;
28957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28958         this_ptr_conv.is_owned = false;
28959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28960         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
28961         return ret_conv;
28962 }
28963
28964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28965         LDKChannelCounterparty this_ptr_conv;
28966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28967         this_ptr_conv.is_owned = false;
28968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28969         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
28970 }
28971
28972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
28973         LDKChannelCounterparty this_ptr_conv;
28974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28975         this_ptr_conv.is_owned = false;
28976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28977         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
28978         int64_t ret_ref = 0;
28979         if ((uintptr_t)ret_var.inner > 4096) {
28980                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28981                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28983                 ret_ref = (uintptr_t)ret_var.inner;
28984                 if (ret_var.is_owned) {
28985                         ret_ref |= 1;
28986                 }
28987         }
28988         return ret_ref;
28989 }
28990
28991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28992         LDKChannelCounterparty this_ptr_conv;
28993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28994         this_ptr_conv.is_owned = false;
28995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28996         LDKCounterpartyForwardingInfo val_conv;
28997         val_conv.inner = (void*)(val & (~1));
28998         val_conv.is_owned = (val & 1) || (val == 0);
28999         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29000         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
29001         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
29002 }
29003
29004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29005         LDKChannelCounterparty this_ptr_conv;
29006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29007         this_ptr_conv.is_owned = false;
29008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29009         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29010         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
29011         int64_t ret_ref = (uintptr_t)ret_copy;
29012         return ret_ref;
29013 }
29014
29015 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) {
29016         LDKChannelCounterparty this_ptr_conv;
29017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29018         this_ptr_conv.is_owned = false;
29019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29020         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29021         CHECK_ACCESS(val_ptr);
29022         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29023         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29024         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
29025 }
29026
29027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29028         LDKChannelCounterparty this_ptr_conv;
29029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29030         this_ptr_conv.is_owned = false;
29031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29032         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29033         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
29034         int64_t ret_ref = (uintptr_t)ret_copy;
29035         return ret_ref;
29036 }
29037
29038 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) {
29039         LDKChannelCounterparty this_ptr_conv;
29040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29041         this_ptr_conv.is_owned = false;
29042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29043         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29044         CHECK_ACCESS(val_ptr);
29045         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29046         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29047         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
29048 }
29049
29050 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) {
29051         LDKPublicKey node_id_arg_ref;
29052         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
29053         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
29054         LDKInitFeatures features_arg_conv;
29055         features_arg_conv.inner = (void*)(features_arg & (~1));
29056         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
29057         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
29058         features_arg_conv = InitFeatures_clone(&features_arg_conv);
29059         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
29060         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
29061         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
29062         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
29063         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
29064         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
29065         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
29066         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
29067         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
29068         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
29069         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
29070         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
29071         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
29072         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);
29073         int64_t ret_ref = 0;
29074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29077         ret_ref = (uintptr_t)ret_var.inner;
29078         if (ret_var.is_owned) {
29079                 ret_ref |= 1;
29080         }
29081         return ret_ref;
29082 }
29083
29084 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
29085         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
29086 int64_t ret_ref = 0;
29087 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29088 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29089 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29090 ret_ref = (uintptr_t)ret_var.inner;
29091 if (ret_var.is_owned) {
29092         ret_ref |= 1;
29093 }
29094         return ret_ref;
29095 }
29096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29097         LDKChannelCounterparty arg_conv;
29098         arg_conv.inner = (void*)(arg & (~1));
29099         arg_conv.is_owned = false;
29100         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29101         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
29102         return ret_conv;
29103 }
29104
29105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29106         LDKChannelCounterparty orig_conv;
29107         orig_conv.inner = (void*)(orig & (~1));
29108         orig_conv.is_owned = false;
29109         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29110         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
29111         int64_t ret_ref = 0;
29112         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29113         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29115         ret_ref = (uintptr_t)ret_var.inner;
29116         if (ret_var.is_owned) {
29117                 ret_ref |= 1;
29118         }
29119         return ret_ref;
29120 }
29121
29122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29123         LDKChannelDetails this_obj_conv;
29124         this_obj_conv.inner = (void*)(this_obj & (~1));
29125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29127         ChannelDetails_free(this_obj_conv);
29128 }
29129
29130 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29131         LDKChannelDetails this_ptr_conv;
29132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29133         this_ptr_conv.is_owned = false;
29134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29135         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29136         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
29137         return ret_arr;
29138 }
29139
29140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29141         LDKChannelDetails this_ptr_conv;
29142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29143         this_ptr_conv.is_owned = false;
29144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29145         LDKThirtyTwoBytes val_ref;
29146         CHECK((*env)->GetArrayLength(env, val) == 32);
29147         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29148         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
29149 }
29150
29151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
29152         LDKChannelDetails this_ptr_conv;
29153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29154         this_ptr_conv.is_owned = false;
29155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29156         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
29157         int64_t ret_ref = 0;
29158         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29159         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29161         ret_ref = (uintptr_t)ret_var.inner;
29162         if (ret_var.is_owned) {
29163                 ret_ref |= 1;
29164         }
29165         return ret_ref;
29166 }
29167
29168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29169         LDKChannelDetails this_ptr_conv;
29170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29171         this_ptr_conv.is_owned = false;
29172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29173         LDKChannelCounterparty val_conv;
29174         val_conv.inner = (void*)(val & (~1));
29175         val_conv.is_owned = (val & 1) || (val == 0);
29176         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29177         val_conv = ChannelCounterparty_clone(&val_conv);
29178         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
29179 }
29180
29181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
29182         LDKChannelDetails this_ptr_conv;
29183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29184         this_ptr_conv.is_owned = false;
29185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29186         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
29187         int64_t ret_ref = 0;
29188         if ((uintptr_t)ret_var.inner > 4096) {
29189                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29190                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29192                 ret_ref = (uintptr_t)ret_var.inner;
29193                 if (ret_var.is_owned) {
29194                         ret_ref |= 1;
29195                 }
29196         }
29197         return ret_ref;
29198 }
29199
29200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29201         LDKChannelDetails this_ptr_conv;
29202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29203         this_ptr_conv.is_owned = false;
29204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29205         LDKOutPoint val_conv;
29206         val_conv.inner = (void*)(val & (~1));
29207         val_conv.is_owned = (val & 1) || (val == 0);
29208         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29209         val_conv = OutPoint_clone(&val_conv);
29210         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
29211 }
29212
29213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
29214         LDKChannelDetails this_ptr_conv;
29215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29216         this_ptr_conv.is_owned = false;
29217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29218         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
29219         int64_t ret_ref = 0;
29220         if ((uintptr_t)ret_var.inner > 4096) {
29221                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29222                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29224                 ret_ref = (uintptr_t)ret_var.inner;
29225                 if (ret_var.is_owned) {
29226                         ret_ref |= 1;
29227                 }
29228         }
29229         return ret_ref;
29230 }
29231
29232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29233         LDKChannelDetails this_ptr_conv;
29234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29235         this_ptr_conv.is_owned = false;
29236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29237         LDKChannelTypeFeatures val_conv;
29238         val_conv.inner = (void*)(val & (~1));
29239         val_conv.is_owned = (val & 1) || (val == 0);
29240         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29241         val_conv = ChannelTypeFeatures_clone(&val_conv);
29242         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
29243 }
29244
29245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29246         LDKChannelDetails this_ptr_conv;
29247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29248         this_ptr_conv.is_owned = false;
29249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29250         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29251         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
29252         int64_t ret_ref = (uintptr_t)ret_copy;
29253         return ret_ref;
29254 }
29255
29256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29257         LDKChannelDetails this_ptr_conv;
29258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29259         this_ptr_conv.is_owned = false;
29260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29261         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29262         CHECK_ACCESS(val_ptr);
29263         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29264         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29265         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
29266 }
29267
29268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29269         LDKChannelDetails this_ptr_conv;
29270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29271         this_ptr_conv.is_owned = false;
29272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29273         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29274         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
29275         int64_t ret_ref = (uintptr_t)ret_copy;
29276         return ret_ref;
29277 }
29278
29279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29280         LDKChannelDetails this_ptr_conv;
29281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29282         this_ptr_conv.is_owned = false;
29283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29284         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29285         CHECK_ACCESS(val_ptr);
29286         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29287         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29288         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
29289 }
29290
29291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
29292         LDKChannelDetails this_ptr_conv;
29293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29294         this_ptr_conv.is_owned = false;
29295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29296         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29297         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
29298         int64_t ret_ref = (uintptr_t)ret_copy;
29299         return ret_ref;
29300 }
29301
29302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29303         LDKChannelDetails this_ptr_conv;
29304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29305         this_ptr_conv.is_owned = false;
29306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29307         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29308         CHECK_ACCESS(val_ptr);
29309         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29310         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29311         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
29312 }
29313
29314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29315         LDKChannelDetails this_ptr_conv;
29316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29317         this_ptr_conv.is_owned = false;
29318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29319         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
29320         return ret_conv;
29321 }
29322
29323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29324         LDKChannelDetails this_ptr_conv;
29325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29326         this_ptr_conv.is_owned = false;
29327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29328         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
29329 }
29330
29331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
29332         LDKChannelDetails this_ptr_conv;
29333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29334         this_ptr_conv.is_owned = false;
29335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29336         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29337         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
29338         int64_t ret_ref = (uintptr_t)ret_copy;
29339         return ret_ref;
29340 }
29341
29342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29343         LDKChannelDetails this_ptr_conv;
29344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29345         this_ptr_conv.is_owned = false;
29346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29347         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29348         CHECK_ACCESS(val_ptr);
29349         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29350         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29351         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
29352 }
29353
29354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29355         LDKChannelDetails this_ptr_conv;
29356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29357         this_ptr_conv.is_owned = false;
29358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29359         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
29360         return ret_conv;
29361 }
29362
29363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29364         LDKChannelDetails this_ptr_conv;
29365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29366         this_ptr_conv.is_owned = false;
29367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29368         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
29369 }
29370
29371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29372         LDKChannelDetails this_ptr_conv;
29373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29374         this_ptr_conv.is_owned = false;
29375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29376         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
29377         return ret_conv;
29378 }
29379
29380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29381         LDKChannelDetails this_ptr_conv;
29382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29383         this_ptr_conv.is_owned = false;
29384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29385         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
29386 }
29387
29388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29389         LDKChannelDetails this_ptr_conv;
29390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29391         this_ptr_conv.is_owned = false;
29392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29393         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
29394         return ret_conv;
29395 }
29396
29397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29398         LDKChannelDetails this_ptr_conv;
29399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29400         this_ptr_conv.is_owned = false;
29401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29402         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
29403 }
29404
29405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29406         LDKChannelDetails this_ptr_conv;
29407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29408         this_ptr_conv.is_owned = false;
29409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29410         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
29411         return ret_conv;
29412 }
29413
29414 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) {
29415         LDKChannelDetails this_ptr_conv;
29416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29417         this_ptr_conv.is_owned = false;
29418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29419         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
29420 }
29421
29422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29423         LDKChannelDetails this_ptr_conv;
29424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29425         this_ptr_conv.is_owned = false;
29426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29427         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
29428         return ret_conv;
29429 }
29430
29431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29432         LDKChannelDetails this_ptr_conv;
29433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29434         this_ptr_conv.is_owned = false;
29435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29436         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
29437 }
29438
29439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
29440         LDKChannelDetails this_ptr_conv;
29441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29442         this_ptr_conv.is_owned = false;
29443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29444         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
29445         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
29446         int64_t ret_ref = (uintptr_t)ret_copy;
29447         return ret_ref;
29448 }
29449
29450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29451         LDKChannelDetails this_ptr_conv;
29452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29453         this_ptr_conv.is_owned = false;
29454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29455         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29456         CHECK_ACCESS(val_ptr);
29457         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
29458         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
29459         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
29460 }
29461
29462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
29463         LDKChannelDetails this_ptr_conv;
29464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29465         this_ptr_conv.is_owned = false;
29466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29467         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
29468         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
29469         int64_t ret_ref = (uintptr_t)ret_copy;
29470         return ret_ref;
29471 }
29472
29473 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) {
29474         LDKChannelDetails this_ptr_conv;
29475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29476         this_ptr_conv.is_owned = false;
29477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29478         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29479         CHECK_ACCESS(val_ptr);
29480         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
29481         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
29482         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
29483 }
29484
29485 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
29486         LDKChannelDetails this_ptr_conv;
29487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29488         this_ptr_conv.is_owned = false;
29489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29490         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
29491         return ret_conv;
29492 }
29493
29494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29495         LDKChannelDetails this_ptr_conv;
29496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29497         this_ptr_conv.is_owned = false;
29498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29499         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
29500 }
29501
29502 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
29503         LDKChannelDetails this_ptr_conv;
29504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29505         this_ptr_conv.is_owned = false;
29506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29507         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
29508         return ret_conv;
29509 }
29510
29511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29512         LDKChannelDetails this_ptr_conv;
29513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29514         this_ptr_conv.is_owned = false;
29515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29516         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
29517 }
29518
29519 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
29520         LDKChannelDetails this_ptr_conv;
29521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29522         this_ptr_conv.is_owned = false;
29523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29524         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
29525         return ret_conv;
29526 }
29527
29528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29529         LDKChannelDetails this_ptr_conv;
29530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29531         this_ptr_conv.is_owned = false;
29532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29533         ChannelDetails_set_is_usable(&this_ptr_conv, val);
29534 }
29535
29536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
29537         LDKChannelDetails this_ptr_conv;
29538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29539         this_ptr_conv.is_owned = false;
29540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29541         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
29542         return ret_conv;
29543 }
29544
29545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29546         LDKChannelDetails this_ptr_conv;
29547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29548         this_ptr_conv.is_owned = false;
29549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29550         ChannelDetails_set_is_public(&this_ptr_conv, val);
29551 }
29552
29553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29554         LDKChannelDetails this_ptr_conv;
29555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29556         this_ptr_conv.is_owned = false;
29557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29558         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29559         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
29560         int64_t ret_ref = (uintptr_t)ret_copy;
29561         return ret_ref;
29562 }
29563
29564 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) {
29565         LDKChannelDetails this_ptr_conv;
29566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29567         this_ptr_conv.is_owned = false;
29568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29569         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29570         CHECK_ACCESS(val_ptr);
29571         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29572         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29573         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
29574 }
29575
29576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29577         LDKChannelDetails this_ptr_conv;
29578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29579         this_ptr_conv.is_owned = false;
29580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29581         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29582         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
29583         int64_t ret_ref = (uintptr_t)ret_copy;
29584         return ret_ref;
29585 }
29586
29587 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) {
29588         LDKChannelDetails this_ptr_conv;
29589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29590         this_ptr_conv.is_owned = false;
29591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29592         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29593         CHECK_ACCESS(val_ptr);
29594         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
29595         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
29596         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
29597 }
29598
29599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
29600         LDKChannelDetails this_ptr_conv;
29601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29602         this_ptr_conv.is_owned = false;
29603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29604         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
29605         int64_t ret_ref = 0;
29606         if ((uintptr_t)ret_var.inner > 4096) {
29607                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29608                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29610                 ret_ref = (uintptr_t)ret_var.inner;
29611                 if (ret_var.is_owned) {
29612                         ret_ref |= 1;
29613                 }
29614         }
29615         return ret_ref;
29616 }
29617
29618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29619         LDKChannelDetails 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         LDKChannelConfig val_conv;
29624         val_conv.inner = (void*)(val & (~1));
29625         val_conv.is_owned = (val & 1) || (val == 0);
29626         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29627         val_conv = ChannelConfig_clone(&val_conv);
29628         ChannelDetails_set_config(&this_ptr_conv, val_conv);
29629 }
29630
29631 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) {
29632         LDKThirtyTwoBytes channel_id_arg_ref;
29633         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
29634         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
29635         LDKChannelCounterparty counterparty_arg_conv;
29636         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
29637         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
29638         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
29639         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
29640         LDKOutPoint funding_txo_arg_conv;
29641         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
29642         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
29643         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
29644         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
29645         LDKChannelTypeFeatures channel_type_arg_conv;
29646         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
29647         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
29648         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
29649         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
29650         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
29651         CHECK_ACCESS(short_channel_id_arg_ptr);
29652         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
29653         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
29654         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
29655         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
29656         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
29657         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
29658         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
29659         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
29660         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
29661         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
29662         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
29663         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
29664         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
29665         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
29666         CHECK_ACCESS(confirmations_required_arg_ptr);
29667         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
29668         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
29669         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
29670         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
29671         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
29672         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
29673         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
29674         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
29675         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
29676         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
29677         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
29678         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
29679         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
29680         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
29681         LDKChannelConfig config_arg_conv;
29682         config_arg_conv.inner = (void*)(config_arg & (~1));
29683         config_arg_conv.is_owned = (config_arg & 1) || (config_arg == 0);
29684         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
29685         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
29686         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);
29687         int64_t ret_ref = 0;
29688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29691         ret_ref = (uintptr_t)ret_var.inner;
29692         if (ret_var.is_owned) {
29693                 ret_ref |= 1;
29694         }
29695         return ret_ref;
29696 }
29697
29698 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
29699         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
29700 int64_t ret_ref = 0;
29701 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29702 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29703 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29704 ret_ref = (uintptr_t)ret_var.inner;
29705 if (ret_var.is_owned) {
29706         ret_ref |= 1;
29707 }
29708         return ret_ref;
29709 }
29710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29711         LDKChannelDetails arg_conv;
29712         arg_conv.inner = (void*)(arg & (~1));
29713         arg_conv.is_owned = false;
29714         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29715         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
29716         return ret_conv;
29717 }
29718
29719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29720         LDKChannelDetails orig_conv;
29721         orig_conv.inner = (void*)(orig & (~1));
29722         orig_conv.is_owned = false;
29723         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29724         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
29725         int64_t ret_ref = 0;
29726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29729         ret_ref = (uintptr_t)ret_var.inner;
29730         if (ret_var.is_owned) {
29731                 ret_ref |= 1;
29732         }
29733         return ret_ref;
29734 }
29735
29736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
29737         LDKChannelDetails this_arg_conv;
29738         this_arg_conv.inner = (void*)(this_arg & (~1));
29739         this_arg_conv.is_owned = false;
29740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29741         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29742         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
29743         int64_t ret_ref = (uintptr_t)ret_copy;
29744         return ret_ref;
29745 }
29746
29747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
29748         LDKChannelDetails this_arg_conv;
29749         this_arg_conv.inner = (void*)(this_arg & (~1));
29750         this_arg_conv.is_owned = false;
29751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29752         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
29753         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
29754         int64_t ret_ref = (uintptr_t)ret_copy;
29755         return ret_ref;
29756 }
29757
29758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29759         if ((this_ptr & 1) != 0) return;
29760         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
29761         CHECK_ACCESS(this_ptr_ptr);
29762         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
29763         FREE((void*)this_ptr);
29764         PaymentSendFailure_free(this_ptr_conv);
29765 }
29766
29767 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
29768         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29769         *ret_copy = PaymentSendFailure_clone(arg);
29770 int64_t ret_ref = (uintptr_t)ret_copy;
29771         return ret_ref;
29772 }
29773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29774         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
29775         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
29776         return ret_conv;
29777 }
29778
29779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29780         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
29781         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29782         *ret_copy = PaymentSendFailure_clone(orig_conv);
29783         int64_t ret_ref = (uintptr_t)ret_copy;
29784         return ret_ref;
29785 }
29786
29787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
29788         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
29789         CHECK_ACCESS(a_ptr);
29790         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
29791         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
29792         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29793         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
29794         int64_t ret_ref = (uintptr_t)ret_copy;
29795         return ret_ref;
29796 }
29797
29798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
29799         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
29800         a_constr.datalen = (*env)->GetArrayLength(env, a);
29801         if (a_constr.datalen > 0)
29802                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
29803         else
29804                 a_constr.data = NULL;
29805         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
29806         for (size_t w = 0; w < a_constr.datalen; w++) {
29807                 int64_t a_conv_22 = a_vals[w];
29808                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
29809                 CHECK_ACCESS(a_conv_22_ptr);
29810                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
29811                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
29812                 a_constr.data[w] = a_conv_22_conv;
29813         }
29814         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
29815         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29816         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
29817         int64_t ret_ref = (uintptr_t)ret_copy;
29818         return ret_ref;
29819 }
29820
29821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
29822         LDKCVec_APIErrorZ a_constr;
29823         a_constr.datalen = (*env)->GetArrayLength(env, a);
29824         if (a_constr.datalen > 0)
29825                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
29826         else
29827                 a_constr.data = NULL;
29828         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
29829         for (size_t k = 0; k < a_constr.datalen; k++) {
29830                 int64_t a_conv_10 = a_vals[k];
29831                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
29832                 CHECK_ACCESS(a_conv_10_ptr);
29833                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
29834                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
29835                 a_constr.data[k] = a_conv_10_conv;
29836         }
29837         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
29838         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29839         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
29840         int64_t ret_ref = (uintptr_t)ret_copy;
29841         return ret_ref;
29842 }
29843
29844 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) {
29845         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
29846         results_constr.datalen = (*env)->GetArrayLength(env, results);
29847         if (results_constr.datalen > 0)
29848                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
29849         else
29850                 results_constr.data = NULL;
29851         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
29852         for (size_t w = 0; w < results_constr.datalen; w++) {
29853                 int64_t results_conv_22 = results_vals[w];
29854                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
29855                 CHECK_ACCESS(results_conv_22_ptr);
29856                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
29857                 results_constr.data[w] = results_conv_22_conv;
29858         }
29859         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
29860         LDKRouteParameters failed_paths_retry_conv;
29861         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
29862         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
29863         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
29864         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
29865         LDKThirtyTwoBytes payment_id_ref;
29866         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29867         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29868         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
29869         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
29870         int64_t ret_ref = (uintptr_t)ret_copy;
29871         return ret_ref;
29872 }
29873
29874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29875         LDKPhantomRouteHints this_obj_conv;
29876         this_obj_conv.inner = (void*)(this_obj & (~1));
29877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29879         PhantomRouteHints_free(this_obj_conv);
29880 }
29881
29882 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
29883         LDKPhantomRouteHints this_ptr_conv;
29884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29885         this_ptr_conv.is_owned = false;
29886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29887         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
29888         int64_tArray ret_arr = NULL;
29889         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29890         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29891         for (size_t q = 0; q < ret_var.datalen; q++) {
29892                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29893                 int64_t ret_conv_16_ref = 0;
29894                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29895                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29896                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29897                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
29898                 if (ret_conv_16_var.is_owned) {
29899                         ret_conv_16_ref |= 1;
29900                 }
29901                 ret_arr_ptr[q] = ret_conv_16_ref;
29902         }
29903         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29904         FREE(ret_var.data);
29905         return ret_arr;
29906 }
29907
29908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
29909         LDKPhantomRouteHints 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         LDKCVec_ChannelDetailsZ val_constr;
29914         val_constr.datalen = (*env)->GetArrayLength(env, val);
29915         if (val_constr.datalen > 0)
29916                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29917         else
29918                 val_constr.data = NULL;
29919         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
29920         for (size_t q = 0; q < val_constr.datalen; q++) {
29921                 int64_t val_conv_16 = val_vals[q];
29922                 LDKChannelDetails val_conv_16_conv;
29923                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
29924                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
29925                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
29926                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
29927                 val_constr.data[q] = val_conv_16_conv;
29928         }
29929         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
29930         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
29931 }
29932
29933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
29934         LDKPhantomRouteHints this_ptr_conv;
29935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29936         this_ptr_conv.is_owned = false;
29937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29938         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
29939         return ret_conv;
29940 }
29941
29942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29943         LDKPhantomRouteHints 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         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
29948 }
29949
29950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
29951         LDKPhantomRouteHints this_ptr_conv;
29952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29953         this_ptr_conv.is_owned = false;
29954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29955         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29956         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
29957         return ret_arr;
29958 }
29959
29960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29961         LDKPhantomRouteHints this_ptr_conv;
29962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29963         this_ptr_conv.is_owned = false;
29964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29965         LDKPublicKey val_ref;
29966         CHECK((*env)->GetArrayLength(env, val) == 33);
29967         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
29968         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
29969 }
29970
29971 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) {
29972         LDKCVec_ChannelDetailsZ channels_arg_constr;
29973         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
29974         if (channels_arg_constr.datalen > 0)
29975                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
29976         else
29977                 channels_arg_constr.data = NULL;
29978         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
29979         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
29980                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
29981                 LDKChannelDetails channels_arg_conv_16_conv;
29982                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
29983                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
29984                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
29985                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
29986                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
29987         }
29988         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
29989         LDKPublicKey real_node_pubkey_arg_ref;
29990         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
29991         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
29992         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
29993         int64_t ret_ref = 0;
29994         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29995         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29997         ret_ref = (uintptr_t)ret_var.inner;
29998         if (ret_var.is_owned) {
29999                 ret_ref |= 1;
30000         }
30001         return ret_ref;
30002 }
30003
30004 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
30005         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
30006 int64_t ret_ref = 0;
30007 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30008 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30009 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30010 ret_ref = (uintptr_t)ret_var.inner;
30011 if (ret_var.is_owned) {
30012         ret_ref |= 1;
30013 }
30014         return ret_ref;
30015 }
30016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30017         LDKPhantomRouteHints arg_conv;
30018         arg_conv.inner = (void*)(arg & (~1));
30019         arg_conv.is_owned = false;
30020         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30021         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
30022         return ret_conv;
30023 }
30024
30025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30026         LDKPhantomRouteHints orig_conv;
30027         orig_conv.inner = (void*)(orig & (~1));
30028         orig_conv.is_owned = false;
30029         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30030         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
30031         int64_t ret_ref = 0;
30032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30035         ret_ref = (uintptr_t)ret_var.inner;
30036         if (ret_var.is_owned) {
30037                 ret_ref |= 1;
30038         }
30039         return ret_ref;
30040 }
30041
30042 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) {
30043         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
30044         CHECK_ACCESS(fee_est_ptr);
30045         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
30046         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
30047                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30048                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
30049         }
30050         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
30051         CHECK_ACCESS(chain_monitor_ptr);
30052         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
30053         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
30054                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30055                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
30056         }
30057         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
30058         CHECK_ACCESS(tx_broadcaster_ptr);
30059         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
30060         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30061                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30062                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
30063         }
30064         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
30065         CHECK_ACCESS(logger_ptr);
30066         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30067         if (logger_conv.free == LDKLogger_JCalls_free) {
30068                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30069                 LDKLogger_JCalls_cloned(&logger_conv);
30070         }
30071         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
30072         CHECK_ACCESS(keys_manager_ptr);
30073         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30074         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30075                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30076                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30077         }
30078         LDKUserConfig config_conv;
30079         config_conv.inner = (void*)(config & (~1));
30080         config_conv.is_owned = (config & 1) || (config == 0);
30081         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
30082         config_conv = UserConfig_clone(&config_conv);
30083         LDKChainParameters params_conv;
30084         params_conv.inner = (void*)(params & (~1));
30085         params_conv.is_owned = (params & 1) || (params == 0);
30086         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
30087         params_conv = ChainParameters_clone(&params_conv);
30088         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
30089         int64_t ret_ref = 0;
30090         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30091         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30093         ret_ref = (uintptr_t)ret_var.inner;
30094         if (ret_var.is_owned) {
30095                 ret_ref |= 1;
30096         }
30097         return ret_ref;
30098 }
30099
30100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
30101         LDKChannelManager this_arg_conv;
30102         this_arg_conv.inner = (void*)(this_arg & (~1));
30103         this_arg_conv.is_owned = false;
30104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30105         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
30106         int64_t ret_ref = 0;
30107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30110         ret_ref = (uintptr_t)ret_var.inner;
30111         if (ret_var.is_owned) {
30112                 ret_ref |= 1;
30113         }
30114         return ret_ref;
30115 }
30116
30117 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) {
30118         LDKChannelManager this_arg_conv;
30119         this_arg_conv.inner = (void*)(this_arg & (~1));
30120         this_arg_conv.is_owned = false;
30121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30122         LDKPublicKey their_network_key_ref;
30123         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
30124         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
30125         LDKUserConfig override_config_conv;
30126         override_config_conv.inner = (void*)(override_config & (~1));
30127         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
30128         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
30129         override_config_conv = UserConfig_clone(&override_config_conv);
30130         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
30131         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
30132         return (int64_t)ret_conv;
30133 }
30134
30135 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30136         LDKChannelManager this_arg_conv;
30137         this_arg_conv.inner = (void*)(this_arg & (~1));
30138         this_arg_conv.is_owned = false;
30139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30140         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
30141         int64_tArray ret_arr = NULL;
30142         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30143         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30144         for (size_t q = 0; q < ret_var.datalen; q++) {
30145                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30146                 int64_t ret_conv_16_ref = 0;
30147                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30148                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30149                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30150                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30151                 if (ret_conv_16_var.is_owned) {
30152                         ret_conv_16_ref |= 1;
30153                 }
30154                 ret_arr_ptr[q] = ret_conv_16_ref;
30155         }
30156         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30157         FREE(ret_var.data);
30158         return ret_arr;
30159 }
30160
30161 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
30162         LDKChannelManager this_arg_conv;
30163         this_arg_conv.inner = (void*)(this_arg & (~1));
30164         this_arg_conv.is_owned = false;
30165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30166         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
30167         int64_tArray ret_arr = NULL;
30168         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30169         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30170         for (size_t q = 0; q < ret_var.datalen; q++) {
30171                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
30172                 int64_t ret_conv_16_ref = 0;
30173                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30174                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30175                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30176                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
30177                 if (ret_conv_16_var.is_owned) {
30178                         ret_conv_16_ref |= 1;
30179                 }
30180                 ret_arr_ptr[q] = ret_conv_16_ref;
30181         }
30182         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30183         FREE(ret_var.data);
30184         return ret_arr;
30185 }
30186
30187 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) {
30188         LDKChannelManager this_arg_conv;
30189         this_arg_conv.inner = (void*)(this_arg & (~1));
30190         this_arg_conv.is_owned = false;
30191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30192         unsigned char channel_id_arr[32];
30193         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30194         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30195         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30196         LDKPublicKey counterparty_node_id_ref;
30197         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30198         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30199         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30200         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30201         return (int64_t)ret_conv;
30202 }
30203
30204 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) {
30205         LDKChannelManager this_arg_conv;
30206         this_arg_conv.inner = (void*)(this_arg & (~1));
30207         this_arg_conv.is_owned = false;
30208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30209         unsigned char channel_id_arr[32];
30210         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30211         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30212         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30213         LDKPublicKey counterparty_node_id_ref;
30214         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30215         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30216         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30217         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
30218         return (int64_t)ret_conv;
30219 }
30220
30221 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) {
30222         LDKChannelManager this_arg_conv;
30223         this_arg_conv.inner = (void*)(this_arg & (~1));
30224         this_arg_conv.is_owned = false;
30225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30226         unsigned char channel_id_arr[32];
30227         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30228         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30229         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30230         LDKPublicKey counterparty_node_id_ref;
30231         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30232         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30233         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30234         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30235         return (int64_t)ret_conv;
30236 }
30237
30238 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) {
30239         LDKChannelManager this_arg_conv;
30240         this_arg_conv.inner = (void*)(this_arg & (~1));
30241         this_arg_conv.is_owned = false;
30242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30243         unsigned char channel_id_arr[32];
30244         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
30245         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
30246         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
30247         LDKPublicKey counterparty_node_id_ref;
30248         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30249         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30250         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30251         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
30252         return (int64_t)ret_conv;
30253 }
30254
30255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30256         LDKChannelManager this_arg_conv;
30257         this_arg_conv.inner = (void*)(this_arg & (~1));
30258         this_arg_conv.is_owned = false;
30259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30260         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
30261 }
30262
30263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
30264         LDKChannelManager this_arg_conv;
30265         this_arg_conv.inner = (void*)(this_arg & (~1));
30266         this_arg_conv.is_owned = false;
30267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30268         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
30269 }
30270
30271 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) {
30272         LDKChannelManager this_arg_conv;
30273         this_arg_conv.inner = (void*)(this_arg & (~1));
30274         this_arg_conv.is_owned = false;
30275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30276         LDKRoute route_conv;
30277         route_conv.inner = (void*)(route & (~1));
30278         route_conv.is_owned = false;
30279         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30280         LDKThirtyTwoBytes payment_hash_ref;
30281         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30282         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30283         LDKThirtyTwoBytes payment_secret_ref;
30284         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
30285         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
30286         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
30287         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
30288         return (int64_t)ret_conv;
30289 }
30290
30291 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) {
30292         LDKChannelManager this_arg_conv;
30293         this_arg_conv.inner = (void*)(this_arg & (~1));
30294         this_arg_conv.is_owned = false;
30295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30296         LDKRoute route_conv;
30297         route_conv.inner = (void*)(route & (~1));
30298         route_conv.is_owned = false;
30299         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30300         LDKThirtyTwoBytes payment_id_ref;
30301         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30302         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30303         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
30304         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
30305         return (int64_t)ret_conv;
30306 }
30307
30308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
30309         LDKChannelManager this_arg_conv;
30310         this_arg_conv.inner = (void*)(this_arg & (~1));
30311         this_arg_conv.is_owned = false;
30312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30313         LDKThirtyTwoBytes payment_id_ref;
30314         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
30315         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
30316         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
30317 }
30318
30319 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) {
30320         LDKChannelManager this_arg_conv;
30321         this_arg_conv.inner = (void*)(this_arg & (~1));
30322         this_arg_conv.is_owned = false;
30323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30324         LDKRoute route_conv;
30325         route_conv.inner = (void*)(route & (~1));
30326         route_conv.is_owned = false;
30327         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
30328         LDKThirtyTwoBytes payment_preimage_ref;
30329         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
30330         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
30331         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
30332         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
30333         return (int64_t)ret_conv;
30334 }
30335
30336 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) {
30337         LDKChannelManager this_arg_conv;
30338         this_arg_conv.inner = (void*)(this_arg & (~1));
30339         this_arg_conv.is_owned = false;
30340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30341         unsigned char temporary_channel_id_arr[32];
30342         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
30343         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
30344         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
30345         LDKPublicKey counterparty_node_id_ref;
30346         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30347         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30348         LDKTransaction funding_transaction_ref;
30349         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
30350         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
30351         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
30352         funding_transaction_ref.data_is_owned = true;
30353         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30354         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
30355         return (int64_t)ret_conv;
30356 }
30357
30358 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) {
30359         LDKChannelManager this_arg_conv;
30360         this_arg_conv.inner = (void*)(this_arg & (~1));
30361         this_arg_conv.is_owned = false;
30362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30363         LDKThreeBytes rgb_ref;
30364         CHECK((*env)->GetArrayLength(env, rgb) == 3);
30365         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
30366         LDKThirtyTwoBytes alias_ref;
30367         CHECK((*env)->GetArrayLength(env, alias) == 32);
30368         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
30369         LDKCVec_NetAddressZ addresses_constr;
30370         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
30371         if (addresses_constr.datalen > 0)
30372                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
30373         else
30374                 addresses_constr.data = NULL;
30375         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
30376         for (size_t m = 0; m < addresses_constr.datalen; m++) {
30377                 int64_t addresses_conv_12 = addresses_vals[m];
30378                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
30379                 CHECK_ACCESS(addresses_conv_12_ptr);
30380                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
30381                 addresses_constr.data[m] = addresses_conv_12_conv;
30382         }
30383         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
30384         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
30385 }
30386
30387 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) {
30388         LDKChannelManager this_arg_conv;
30389         this_arg_conv.inner = (void*)(this_arg & (~1));
30390         this_arg_conv.is_owned = false;
30391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30392         LDKPublicKey counterparty_node_id_ref;
30393         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30394         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30395         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
30396         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
30397         if (channel_ids_constr.datalen > 0)
30398                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
30399         else
30400                 channel_ids_constr.data = NULL;
30401         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
30402                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
30403                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
30404                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
30405                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
30406                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
30407         }
30408         LDKChannelConfig config_conv;
30409         config_conv.inner = (void*)(config & (~1));
30410         config_conv.is_owned = false;
30411         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
30412         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30413         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
30414         return (int64_t)ret_conv;
30415 }
30416
30417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
30418         LDKChannelManager this_arg_conv;
30419         this_arg_conv.inner = (void*)(this_arg & (~1));
30420         this_arg_conv.is_owned = false;
30421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30422         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
30423 }
30424
30425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
30426         LDKChannelManager this_arg_conv;
30427         this_arg_conv.inner = (void*)(this_arg & (~1));
30428         this_arg_conv.is_owned = false;
30429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30430         ChannelManager_timer_tick_occurred(&this_arg_conv);
30431 }
30432
30433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
30434         LDKChannelManager this_arg_conv;
30435         this_arg_conv.inner = (void*)(this_arg & (~1));
30436         this_arg_conv.is_owned = false;
30437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30438         unsigned char payment_hash_arr[32];
30439         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30440         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
30441         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
30442         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
30443 }
30444
30445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
30446         LDKChannelManager this_arg_conv;
30447         this_arg_conv.inner = (void*)(this_arg & (~1));
30448         this_arg_conv.is_owned = false;
30449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30450         LDKThirtyTwoBytes payment_preimage_ref;
30451         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
30452         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
30453         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
30454 }
30455
30456 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
30457         LDKChannelManager this_arg_conv;
30458         this_arg_conv.inner = (void*)(this_arg & (~1));
30459         this_arg_conv.is_owned = false;
30460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30461         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30462         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
30463         return ret_arr;
30464 }
30465
30466 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) {
30467         LDKChannelManager this_arg_conv;
30468         this_arg_conv.inner = (void*)(this_arg & (~1));
30469         this_arg_conv.is_owned = false;
30470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30471         unsigned char temporary_channel_id_arr[32];
30472         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
30473         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
30474         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
30475         LDKPublicKey counterparty_node_id_ref;
30476         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30477         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30478         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30479         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
30480         return (int64_t)ret_conv;
30481 }
30482
30483 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) {
30484         LDKChannelManager this_arg_conv;
30485         this_arg_conv.inner = (void*)(this_arg & (~1));
30486         this_arg_conv.is_owned = false;
30487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30488         unsigned char temporary_channel_id_arr[32];
30489         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
30490         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
30491         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
30492         LDKPublicKey counterparty_node_id_ref;
30493         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
30494         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
30495         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
30496         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
30497         return (int64_t)ret_conv;
30498 }
30499
30500 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) {
30501         LDKChannelManager this_arg_conv;
30502         this_arg_conv.inner = (void*)(this_arg & (~1));
30503         this_arg_conv.is_owned = false;
30504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30505         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30506         CHECK_ACCESS(min_value_msat_ptr);
30507         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30508         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30509         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
30510         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
30511         return (int64_t)ret_conv;
30512 }
30513
30514 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) {
30515         LDKChannelManager this_arg_conv;
30516         this_arg_conv.inner = (void*)(this_arg & (~1));
30517         this_arg_conv.is_owned = false;
30518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30519         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30520         CHECK_ACCESS(min_value_msat_ptr);
30521         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30522         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30523         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
30524         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
30525         return (int64_t)ret_conv;
30526 }
30527
30528 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) {
30529         LDKChannelManager this_arg_conv;
30530         this_arg_conv.inner = (void*)(this_arg & (~1));
30531         this_arg_conv.is_owned = false;
30532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30533         LDKThirtyTwoBytes payment_hash_ref;
30534         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30535         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30536         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30537         CHECK_ACCESS(min_value_msat_ptr);
30538         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30539         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30540         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
30541         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
30542         return (int64_t)ret_conv;
30543 }
30544
30545 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) {
30546         LDKChannelManager this_arg_conv;
30547         this_arg_conv.inner = (void*)(this_arg & (~1));
30548         this_arg_conv.is_owned = false;
30549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30550         LDKThirtyTwoBytes payment_hash_ref;
30551         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30552         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30553         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
30554         CHECK_ACCESS(min_value_msat_ptr);
30555         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
30556         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
30557         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
30558         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
30559         return (int64_t)ret_conv;
30560 }
30561
30562 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) {
30563         LDKChannelManager this_arg_conv;
30564         this_arg_conv.inner = (void*)(this_arg & (~1));
30565         this_arg_conv.is_owned = false;
30566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30567         LDKThirtyTwoBytes payment_hash_ref;
30568         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
30569         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
30570         LDKThirtyTwoBytes payment_secret_ref;
30571         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
30572         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
30573         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
30574         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
30575         return (int64_t)ret_conv;
30576 }
30577
30578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30579         LDKChannelManager this_arg_conv;
30580         this_arg_conv.inner = (void*)(this_arg & (~1));
30581         this_arg_conv.is_owned = false;
30582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30583         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
30584         return ret_conv;
30585 }
30586
30587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
30588         LDKChannelManager this_arg_conv;
30589         this_arg_conv.inner = (void*)(this_arg & (~1));
30590         this_arg_conv.is_owned = false;
30591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30592         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
30593         int64_t ret_ref = 0;
30594         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30595         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30597         ret_ref = (uintptr_t)ret_var.inner;
30598         if (ret_var.is_owned) {
30599                 ret_ref |= 1;
30600         }
30601         return ret_ref;
30602 }
30603
30604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
30605         LDKChannelManager this_arg_conv;
30606         this_arg_conv.inner = (void*)(this_arg & (~1));
30607         this_arg_conv.is_owned = false;
30608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30609         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
30610         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
30611         return (int64_t)ret_ret;
30612 }
30613
30614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
30615         LDKChannelManager this_arg_conv;
30616         this_arg_conv.inner = (void*)(this_arg & (~1));
30617         this_arg_conv.is_owned = false;
30618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30619         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
30620         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
30621         return (int64_t)ret_ret;
30622 }
30623
30624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
30625         LDKChannelManager this_arg_conv;
30626         this_arg_conv.inner = (void*)(this_arg & (~1));
30627         this_arg_conv.is_owned = false;
30628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30629         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
30630         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
30631         return (int64_t)ret_ret;
30632 }
30633
30634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
30635         LDKChannelManager this_arg_conv;
30636         this_arg_conv.inner = (void*)(this_arg & (~1));
30637         this_arg_conv.is_owned = false;
30638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30639         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
30640         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
30641         return (int64_t)ret_ret;
30642 }
30643
30644 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) {
30645         LDKChannelManager this_arg_conv;
30646         this_arg_conv.inner = (void*)(this_arg & (~1));
30647         this_arg_conv.is_owned = false;
30648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30649         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
30650         return ret_conv;
30651 }
30652
30653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
30654         LDKChannelManager this_arg_conv;
30655         this_arg_conv.inner = (void*)(this_arg & (~1));
30656         this_arg_conv.is_owned = false;
30657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30658         ChannelManager_await_persistable_update(&this_arg_conv);
30659 }
30660
30661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
30662         LDKChannelManager this_arg_conv;
30663         this_arg_conv.inner = (void*)(this_arg & (~1));
30664         this_arg_conv.is_owned = false;
30665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30666         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
30667         int64_t ret_ref = 0;
30668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30671         ret_ref = (uintptr_t)ret_var.inner;
30672         if (ret_var.is_owned) {
30673                 ret_ref |= 1;
30674         }
30675         return ret_ref;
30676 }
30677
30678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
30679         LDKChannelManager this_arg_conv;
30680         this_arg_conv.inner = (void*)(this_arg & (~1));
30681         this_arg_conv.is_owned = false;
30682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30683         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
30684         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
30685         return (int64_t)ret_ret;
30686 }
30687
30688 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
30689         LDKCounterpartyForwardingInfo obj_conv;
30690         obj_conv.inner = (void*)(obj & (~1));
30691         obj_conv.is_owned = false;
30692         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30693         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
30694         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30695         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30696         CVec_u8Z_free(ret_var);
30697         return ret_arr;
30698 }
30699
30700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30701         LDKu8slice ser_ref;
30702         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30703         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30704         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
30705         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
30706         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30707         return (int64_t)ret_conv;
30708 }
30709
30710 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
30711         LDKChannelCounterparty obj_conv;
30712         obj_conv.inner = (void*)(obj & (~1));
30713         obj_conv.is_owned = false;
30714         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30715         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
30716         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30717         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30718         CVec_u8Z_free(ret_var);
30719         return ret_arr;
30720 }
30721
30722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30723         LDKu8slice ser_ref;
30724         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30725         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30726         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
30727         *ret_conv = ChannelCounterparty_read(ser_ref);
30728         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30729         return (int64_t)ret_conv;
30730 }
30731
30732 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
30733         LDKChannelDetails obj_conv;
30734         obj_conv.inner = (void*)(obj & (~1));
30735         obj_conv.is_owned = false;
30736         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30737         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
30738         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30739         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30740         CVec_u8Z_free(ret_var);
30741         return ret_arr;
30742 }
30743
30744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30745         LDKu8slice ser_ref;
30746         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30747         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30748         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
30749         *ret_conv = ChannelDetails_read(ser_ref);
30750         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30751         return (int64_t)ret_conv;
30752 }
30753
30754 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
30755         LDKPhantomRouteHints obj_conv;
30756         obj_conv.inner = (void*)(obj & (~1));
30757         obj_conv.is_owned = false;
30758         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30759         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
30760         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30761         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30762         CVec_u8Z_free(ret_var);
30763         return ret_arr;
30764 }
30765
30766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30767         LDKu8slice ser_ref;
30768         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30769         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30770         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
30771         *ret_conv = PhantomRouteHints_read(ser_ref);
30772         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30773         return (int64_t)ret_conv;
30774 }
30775
30776 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
30777         LDKChannelManager obj_conv;
30778         obj_conv.inner = (void*)(obj & (~1));
30779         obj_conv.is_owned = false;
30780         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30781         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
30782         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30783         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30784         CVec_u8Z_free(ret_var);
30785         return ret_arr;
30786 }
30787
30788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30789         LDKChannelManagerReadArgs this_obj_conv;
30790         this_obj_conv.inner = (void*)(this_obj & (~1));
30791         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30793         ChannelManagerReadArgs_free(this_obj_conv);
30794 }
30795
30796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
30797         LDKChannelManagerReadArgs this_ptr_conv;
30798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30799         this_ptr_conv.is_owned = false;
30800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30801         // WARNING: This object doesn't live past this scope, needs clone!
30802         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
30803         return ret_ret;
30804 }
30805
30806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30807         LDKChannelManagerReadArgs this_ptr_conv;
30808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30809         this_ptr_conv.is_owned = false;
30810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30811         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30812         CHECK_ACCESS(val_ptr);
30813         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
30814         if (val_conv.free == LDKKeysInterface_JCalls_free) {
30815                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30816                 LDKKeysInterface_JCalls_cloned(&val_conv);
30817         }
30818         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
30819 }
30820
30821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
30822         LDKChannelManagerReadArgs this_ptr_conv;
30823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30824         this_ptr_conv.is_owned = false;
30825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30826         // WARNING: This object doesn't live past this scope, needs clone!
30827         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
30828         return ret_ret;
30829 }
30830
30831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30832         LDKChannelManagerReadArgs this_ptr_conv;
30833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30834         this_ptr_conv.is_owned = false;
30835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30836         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30837         CHECK_ACCESS(val_ptr);
30838         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
30839         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
30840                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30841                 LDKFeeEstimator_JCalls_cloned(&val_conv);
30842         }
30843         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
30844 }
30845
30846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
30847         LDKChannelManagerReadArgs this_ptr_conv;
30848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30849         this_ptr_conv.is_owned = false;
30850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30851         // WARNING: This object doesn't live past this scope, needs clone!
30852         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
30853         return ret_ret;
30854 }
30855
30856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30857         LDKChannelManagerReadArgs this_ptr_conv;
30858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30859         this_ptr_conv.is_owned = false;
30860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30861         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30862         CHECK_ACCESS(val_ptr);
30863         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
30864         if (val_conv.free == LDKWatch_JCalls_free) {
30865                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30866                 LDKWatch_JCalls_cloned(&val_conv);
30867         }
30868         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
30869 }
30870
30871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
30872         LDKChannelManagerReadArgs this_ptr_conv;
30873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30874         this_ptr_conv.is_owned = false;
30875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30876         // WARNING: This object doesn't live past this scope, needs clone!
30877         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
30878         return ret_ret;
30879 }
30880
30881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30882         LDKChannelManagerReadArgs this_ptr_conv;
30883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30884         this_ptr_conv.is_owned = false;
30885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30886         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30887         CHECK_ACCESS(val_ptr);
30888         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
30889         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
30890                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30891                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
30892         }
30893         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
30894 }
30895
30896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
30897         LDKChannelManagerReadArgs this_ptr_conv;
30898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30899         this_ptr_conv.is_owned = false;
30900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30901         // WARNING: This object doesn't live past this scope, needs clone!
30902         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
30903         return ret_ret;
30904 }
30905
30906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30907         LDKChannelManagerReadArgs this_ptr_conv;
30908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30909         this_ptr_conv.is_owned = false;
30910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30911         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
30912         CHECK_ACCESS(val_ptr);
30913         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
30914         if (val_conv.free == LDKLogger_JCalls_free) {
30915                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30916                 LDKLogger_JCalls_cloned(&val_conv);
30917         }
30918         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
30919 }
30920
30921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
30922         LDKChannelManagerReadArgs this_ptr_conv;
30923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30924         this_ptr_conv.is_owned = false;
30925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30926         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
30927         int64_t ret_ref = 0;
30928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30931         ret_ref = (uintptr_t)ret_var.inner;
30932         if (ret_var.is_owned) {
30933                 ret_ref |= 1;
30934         }
30935         return ret_ref;
30936 }
30937
30938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30939         LDKChannelManagerReadArgs this_ptr_conv;
30940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30941         this_ptr_conv.is_owned = false;
30942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30943         LDKUserConfig val_conv;
30944         val_conv.inner = (void*)(val & (~1));
30945         val_conv.is_owned = (val & 1) || (val == 0);
30946         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30947         val_conv = UserConfig_clone(&val_conv);
30948         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
30949 }
30950
30951 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) {
30952         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
30953         CHECK_ACCESS(keys_manager_ptr);
30954         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
30955         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
30956                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30957                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
30958         }
30959         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
30960         CHECK_ACCESS(fee_estimator_ptr);
30961         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
30962         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
30963                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30964                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
30965         }
30966         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
30967         CHECK_ACCESS(chain_monitor_ptr);
30968         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
30969         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
30970                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30971                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
30972         }
30973         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
30974         CHECK_ACCESS(tx_broadcaster_ptr);
30975         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
30976         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
30977                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30978                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
30979         }
30980         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
30981         CHECK_ACCESS(logger_ptr);
30982         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30983         if (logger_conv.free == LDKLogger_JCalls_free) {
30984                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30985                 LDKLogger_JCalls_cloned(&logger_conv);
30986         }
30987         LDKUserConfig default_config_conv;
30988         default_config_conv.inner = (void*)(default_config & (~1));
30989         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
30990         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
30991         default_config_conv = UserConfig_clone(&default_config_conv);
30992         LDKCVec_ChannelMonitorZ channel_monitors_constr;
30993         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
30994         if (channel_monitors_constr.datalen > 0)
30995                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
30996         else
30997                 channel_monitors_constr.data = NULL;
30998         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
30999         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
31000                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
31001                 LDKChannelMonitor channel_monitors_conv_16_conv;
31002                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
31003                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
31004                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
31005                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
31006         }
31007         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
31008         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);
31009         int64_t ret_ref = 0;
31010         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31011         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31013         ret_ref = (uintptr_t)ret_var.inner;
31014         if (ret_var.is_owned) {
31015                 ret_ref |= 1;
31016         }
31017         return ret_ref;
31018 }
31019
31020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
31021         LDKu8slice ser_ref;
31022         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31023         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31024         LDKChannelManagerReadArgs arg_conv;
31025         arg_conv.inner = (void*)(arg & (~1));
31026         arg_conv.is_owned = (arg & 1) || (arg == 0);
31027         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31028         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
31029         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
31030         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
31031         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31032         return (int64_t)ret_conv;
31033 }
31034
31035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31036         LDKExpandedKey this_obj_conv;
31037         this_obj_conv.inner = (void*)(this_obj & (~1));
31038         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31040         ExpandedKey_free(this_obj_conv);
31041 }
31042
31043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
31044         unsigned char key_material_arr[32];
31045         CHECK((*env)->GetArrayLength(env, key_material) == 32);
31046         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
31047         unsigned char (*key_material_ref)[32] = &key_material_arr;
31048         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
31049         int64_t ret_ref = 0;
31050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31053         ret_ref = (uintptr_t)ret_var.inner;
31054         if (ret_var.is_owned) {
31055                 ret_ref |= 1;
31056         }
31057         return ret_ref;
31058 }
31059
31060 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) {
31061         LDKExpandedKey keys_conv;
31062         keys_conv.inner = (void*)(keys & (~1));
31063         keys_conv.is_owned = false;
31064         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31065         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31066         CHECK_ACCESS(min_value_msat_ptr);
31067         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31068         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31069         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
31070         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
31071         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
31072         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
31073         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
31074         return (int64_t)ret_conv;
31075 }
31076
31077 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) {
31078         LDKExpandedKey keys_conv;
31079         keys_conv.inner = (void*)(keys & (~1));
31080         keys_conv.is_owned = false;
31081         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
31082         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
31083         CHECK_ACCESS(min_value_msat_ptr);
31084         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31085         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
31086         LDKThirtyTwoBytes payment_hash_ref;
31087         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31088         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31089         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
31090         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
31091         return (int64_t)ret_conv;
31092 }
31093
31094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31095         LDKDecodeError this_obj_conv;
31096         this_obj_conv.inner = (void*)(this_obj & (~1));
31097         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31099         DecodeError_free(this_obj_conv);
31100 }
31101
31102 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
31103         LDKDecodeError ret_var = DecodeError_clone(arg);
31104 int64_t ret_ref = 0;
31105 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31106 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31107 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31108 ret_ref = (uintptr_t)ret_var.inner;
31109 if (ret_var.is_owned) {
31110         ret_ref |= 1;
31111 }
31112         return ret_ref;
31113 }
31114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31115         LDKDecodeError arg_conv;
31116         arg_conv.inner = (void*)(arg & (~1));
31117         arg_conv.is_owned = false;
31118         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31119         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
31120         return ret_conv;
31121 }
31122
31123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31124         LDKDecodeError orig_conv;
31125         orig_conv.inner = (void*)(orig & (~1));
31126         orig_conv.is_owned = false;
31127         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31128         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
31129         int64_t ret_ref = 0;
31130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31133         ret_ref = (uintptr_t)ret_var.inner;
31134         if (ret_var.is_owned) {
31135                 ret_ref |= 1;
31136         }
31137         return ret_ref;
31138 }
31139
31140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31141         LDKInit this_obj_conv;
31142         this_obj_conv.inner = (void*)(this_obj & (~1));
31143         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31145         Init_free(this_obj_conv);
31146 }
31147
31148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
31149         LDKInit this_ptr_conv;
31150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31151         this_ptr_conv.is_owned = false;
31152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31153         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
31154         int64_t ret_ref = 0;
31155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31158         ret_ref = (uintptr_t)ret_var.inner;
31159         if (ret_var.is_owned) {
31160                 ret_ref |= 1;
31161         }
31162         return ret_ref;
31163 }
31164
31165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31166         LDKInit this_ptr_conv;
31167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31168         this_ptr_conv.is_owned = false;
31169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31170         LDKInitFeatures val_conv;
31171         val_conv.inner = (void*)(val & (~1));
31172         val_conv.is_owned = (val & 1) || (val == 0);
31173         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31174         val_conv = InitFeatures_clone(&val_conv);
31175         Init_set_features(&this_ptr_conv, val_conv);
31176 }
31177
31178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
31179         LDKInit this_ptr_conv;
31180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31181         this_ptr_conv.is_owned = false;
31182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31183         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
31184         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
31185         int64_t ret_ref = (uintptr_t)ret_copy;
31186         return ret_ref;
31187 }
31188
31189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31190         LDKInit this_ptr_conv;
31191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31192         this_ptr_conv.is_owned = false;
31193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31194         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31195         CHECK_ACCESS(val_ptr);
31196         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
31197         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
31198         Init_set_remote_network_address(&this_ptr_conv, val_conv);
31199 }
31200
31201 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) {
31202         LDKInitFeatures features_arg_conv;
31203         features_arg_conv.inner = (void*)(features_arg & (~1));
31204         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
31205         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
31206         features_arg_conv = InitFeatures_clone(&features_arg_conv);
31207         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
31208         CHECK_ACCESS(remote_network_address_arg_ptr);
31209         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
31210         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
31211         int64_t ret_ref = 0;
31212         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31213         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31215         ret_ref = (uintptr_t)ret_var.inner;
31216         if (ret_var.is_owned) {
31217                 ret_ref |= 1;
31218         }
31219         return ret_ref;
31220 }
31221
31222 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
31223         LDKInit ret_var = Init_clone(arg);
31224 int64_t ret_ref = 0;
31225 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31226 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31227 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31228 ret_ref = (uintptr_t)ret_var.inner;
31229 if (ret_var.is_owned) {
31230         ret_ref |= 1;
31231 }
31232         return ret_ref;
31233 }
31234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31235         LDKInit arg_conv;
31236         arg_conv.inner = (void*)(arg & (~1));
31237         arg_conv.is_owned = false;
31238         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31239         int64_t ret_conv = Init_clone_ptr(&arg_conv);
31240         return ret_conv;
31241 }
31242
31243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31244         LDKInit orig_conv;
31245         orig_conv.inner = (void*)(orig & (~1));
31246         orig_conv.is_owned = false;
31247         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31248         LDKInit ret_var = Init_clone(&orig_conv);
31249         int64_t ret_ref = 0;
31250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31253         ret_ref = (uintptr_t)ret_var.inner;
31254         if (ret_var.is_owned) {
31255                 ret_ref |= 1;
31256         }
31257         return ret_ref;
31258 }
31259
31260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31261         LDKErrorMessage this_obj_conv;
31262         this_obj_conv.inner = (void*)(this_obj & (~1));
31263         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31265         ErrorMessage_free(this_obj_conv);
31266 }
31267
31268 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31269         LDKErrorMessage this_ptr_conv;
31270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31271         this_ptr_conv.is_owned = false;
31272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31273         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31274         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
31275         return ret_arr;
31276 }
31277
31278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31279         LDKErrorMessage this_ptr_conv;
31280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31281         this_ptr_conv.is_owned = false;
31282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31283         LDKThirtyTwoBytes val_ref;
31284         CHECK((*env)->GetArrayLength(env, val) == 32);
31285         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31286         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
31287 }
31288
31289 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
31290         LDKErrorMessage this_ptr_conv;
31291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31292         this_ptr_conv.is_owned = false;
31293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31294         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
31295         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31296         Str_free(ret_str);
31297         return ret_conv;
31298 }
31299
31300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
31301         LDKErrorMessage this_ptr_conv;
31302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31303         this_ptr_conv.is_owned = false;
31304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31305         LDKStr val_conv = java_to_owned_str(env, val);
31306         ErrorMessage_set_data(&this_ptr_conv, val_conv);
31307 }
31308
31309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
31310         LDKThirtyTwoBytes channel_id_arg_ref;
31311         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31312         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31313         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
31314         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
31315         int64_t ret_ref = 0;
31316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31319         ret_ref = (uintptr_t)ret_var.inner;
31320         if (ret_var.is_owned) {
31321                 ret_ref |= 1;
31322         }
31323         return ret_ref;
31324 }
31325
31326 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
31327         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
31328 int64_t ret_ref = 0;
31329 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31330 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31331 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31332 ret_ref = (uintptr_t)ret_var.inner;
31333 if (ret_var.is_owned) {
31334         ret_ref |= 1;
31335 }
31336         return ret_ref;
31337 }
31338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31339         LDKErrorMessage arg_conv;
31340         arg_conv.inner = (void*)(arg & (~1));
31341         arg_conv.is_owned = false;
31342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31343         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
31344         return ret_conv;
31345 }
31346
31347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31348         LDKErrorMessage orig_conv;
31349         orig_conv.inner = (void*)(orig & (~1));
31350         orig_conv.is_owned = false;
31351         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31352         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
31353         int64_t ret_ref = 0;
31354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31357         ret_ref = (uintptr_t)ret_var.inner;
31358         if (ret_var.is_owned) {
31359                 ret_ref |= 1;
31360         }
31361         return ret_ref;
31362 }
31363
31364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31365         LDKWarningMessage this_obj_conv;
31366         this_obj_conv.inner = (void*)(this_obj & (~1));
31367         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31369         WarningMessage_free(this_obj_conv);
31370 }
31371
31372 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31373         LDKWarningMessage this_ptr_conv;
31374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31375         this_ptr_conv.is_owned = false;
31376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31377         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31378         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
31379         return ret_arr;
31380 }
31381
31382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31383         LDKWarningMessage this_ptr_conv;
31384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31385         this_ptr_conv.is_owned = false;
31386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31387         LDKThirtyTwoBytes val_ref;
31388         CHECK((*env)->GetArrayLength(env, val) == 32);
31389         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31390         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
31391 }
31392
31393 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
31394         LDKWarningMessage this_ptr_conv;
31395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31396         this_ptr_conv.is_owned = false;
31397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31398         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
31399         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
31400         Str_free(ret_str);
31401         return ret_conv;
31402 }
31403
31404 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
31405         LDKWarningMessage this_ptr_conv;
31406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31407         this_ptr_conv.is_owned = false;
31408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31409         LDKStr val_conv = java_to_owned_str(env, val);
31410         WarningMessage_set_data(&this_ptr_conv, val_conv);
31411 }
31412
31413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
31414         LDKThirtyTwoBytes channel_id_arg_ref;
31415         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31416         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31417         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
31418         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
31419         int64_t ret_ref = 0;
31420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31423         ret_ref = (uintptr_t)ret_var.inner;
31424         if (ret_var.is_owned) {
31425                 ret_ref |= 1;
31426         }
31427         return ret_ref;
31428 }
31429
31430 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
31431         LDKWarningMessage ret_var = WarningMessage_clone(arg);
31432 int64_t ret_ref = 0;
31433 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31434 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31435 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31436 ret_ref = (uintptr_t)ret_var.inner;
31437 if (ret_var.is_owned) {
31438         ret_ref |= 1;
31439 }
31440         return ret_ref;
31441 }
31442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31443         LDKWarningMessage arg_conv;
31444         arg_conv.inner = (void*)(arg & (~1));
31445         arg_conv.is_owned = false;
31446         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31447         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
31448         return ret_conv;
31449 }
31450
31451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31452         LDKWarningMessage orig_conv;
31453         orig_conv.inner = (void*)(orig & (~1));
31454         orig_conv.is_owned = false;
31455         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31456         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
31457         int64_t ret_ref = 0;
31458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31461         ret_ref = (uintptr_t)ret_var.inner;
31462         if (ret_var.is_owned) {
31463                 ret_ref |= 1;
31464         }
31465         return ret_ref;
31466 }
31467
31468 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31469         LDKPing this_obj_conv;
31470         this_obj_conv.inner = (void*)(this_obj & (~1));
31471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31473         Ping_free(this_obj_conv);
31474 }
31475
31476 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
31477         LDKPing this_ptr_conv;
31478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31479         this_ptr_conv.is_owned = false;
31480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31481         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
31482         return ret_conv;
31483 }
31484
31485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31486         LDKPing this_ptr_conv;
31487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31488         this_ptr_conv.is_owned = false;
31489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31490         Ping_set_ponglen(&this_ptr_conv, val);
31491 }
31492
31493 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
31494         LDKPing this_ptr_conv;
31495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31496         this_ptr_conv.is_owned = false;
31497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31498         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
31499         return ret_conv;
31500 }
31501
31502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31503         LDKPing this_ptr_conv;
31504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31505         this_ptr_conv.is_owned = false;
31506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31507         Ping_set_byteslen(&this_ptr_conv, val);
31508 }
31509
31510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
31511         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
31512         int64_t ret_ref = 0;
31513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31516         ret_ref = (uintptr_t)ret_var.inner;
31517         if (ret_var.is_owned) {
31518                 ret_ref |= 1;
31519         }
31520         return ret_ref;
31521 }
31522
31523 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
31524         LDKPing ret_var = Ping_clone(arg);
31525 int64_t ret_ref = 0;
31526 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31527 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31528 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31529 ret_ref = (uintptr_t)ret_var.inner;
31530 if (ret_var.is_owned) {
31531         ret_ref |= 1;
31532 }
31533         return ret_ref;
31534 }
31535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31536         LDKPing arg_conv;
31537         arg_conv.inner = (void*)(arg & (~1));
31538         arg_conv.is_owned = false;
31539         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31540         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
31541         return ret_conv;
31542 }
31543
31544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31545         LDKPing orig_conv;
31546         orig_conv.inner = (void*)(orig & (~1));
31547         orig_conv.is_owned = false;
31548         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31549         LDKPing ret_var = Ping_clone(&orig_conv);
31550         int64_t ret_ref = 0;
31551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31554         ret_ref = (uintptr_t)ret_var.inner;
31555         if (ret_var.is_owned) {
31556                 ret_ref |= 1;
31557         }
31558         return ret_ref;
31559 }
31560
31561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31562         LDKPong this_obj_conv;
31563         this_obj_conv.inner = (void*)(this_obj & (~1));
31564         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31566         Pong_free(this_obj_conv);
31567 }
31568
31569 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
31570         LDKPong this_ptr_conv;
31571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31572         this_ptr_conv.is_owned = false;
31573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31574         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
31575         return ret_conv;
31576 }
31577
31578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31579         LDKPong this_ptr_conv;
31580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31581         this_ptr_conv.is_owned = false;
31582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31583         Pong_set_byteslen(&this_ptr_conv, val);
31584 }
31585
31586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
31587         LDKPong ret_var = Pong_new(byteslen_arg);
31588         int64_t ret_ref = 0;
31589         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31590         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31592         ret_ref = (uintptr_t)ret_var.inner;
31593         if (ret_var.is_owned) {
31594                 ret_ref |= 1;
31595         }
31596         return ret_ref;
31597 }
31598
31599 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
31600         LDKPong ret_var = Pong_clone(arg);
31601 int64_t ret_ref = 0;
31602 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31603 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31604 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31605 ret_ref = (uintptr_t)ret_var.inner;
31606 if (ret_var.is_owned) {
31607         ret_ref |= 1;
31608 }
31609         return ret_ref;
31610 }
31611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31612         LDKPong arg_conv;
31613         arg_conv.inner = (void*)(arg & (~1));
31614         arg_conv.is_owned = false;
31615         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31616         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
31617         return ret_conv;
31618 }
31619
31620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31621         LDKPong orig_conv;
31622         orig_conv.inner = (void*)(orig & (~1));
31623         orig_conv.is_owned = false;
31624         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31625         LDKPong ret_var = Pong_clone(&orig_conv);
31626         int64_t ret_ref = 0;
31627         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31628         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31630         ret_ref = (uintptr_t)ret_var.inner;
31631         if (ret_var.is_owned) {
31632                 ret_ref |= 1;
31633         }
31634         return ret_ref;
31635 }
31636
31637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31638         LDKOpenChannel this_obj_conv;
31639         this_obj_conv.inner = (void*)(this_obj & (~1));
31640         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31642         OpenChannel_free(this_obj_conv);
31643 }
31644
31645 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31646         LDKOpenChannel this_ptr_conv;
31647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31648         this_ptr_conv.is_owned = false;
31649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31650         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31651         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
31652         return ret_arr;
31653 }
31654
31655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31656         LDKOpenChannel this_ptr_conv;
31657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31658         this_ptr_conv.is_owned = false;
31659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31660         LDKThirtyTwoBytes val_ref;
31661         CHECK((*env)->GetArrayLength(env, val) == 32);
31662         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31663         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
31664 }
31665
31666 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31667         LDKOpenChannel this_ptr_conv;
31668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31669         this_ptr_conv.is_owned = false;
31670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31671         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31672         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
31673         return ret_arr;
31674 }
31675
31676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31677         LDKOpenChannel this_ptr_conv;
31678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31679         this_ptr_conv.is_owned = false;
31680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31681         LDKThirtyTwoBytes val_ref;
31682         CHECK((*env)->GetArrayLength(env, val) == 32);
31683         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31684         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
31685 }
31686
31687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31688         LDKOpenChannel this_ptr_conv;
31689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31690         this_ptr_conv.is_owned = false;
31691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31692         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
31693         return ret_conv;
31694 }
31695
31696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31697         LDKOpenChannel this_ptr_conv;
31698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31699         this_ptr_conv.is_owned = false;
31700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31701         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
31702 }
31703
31704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31705         LDKOpenChannel this_ptr_conv;
31706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31707         this_ptr_conv.is_owned = false;
31708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31709         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
31710         return ret_conv;
31711 }
31712
31713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31714         LDKOpenChannel this_ptr_conv;
31715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31716         this_ptr_conv.is_owned = false;
31717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31718         OpenChannel_set_push_msat(&this_ptr_conv, val);
31719 }
31720
31721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31722         LDKOpenChannel this_ptr_conv;
31723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31724         this_ptr_conv.is_owned = false;
31725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31726         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
31727         return ret_conv;
31728 }
31729
31730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31731         LDKOpenChannel this_ptr_conv;
31732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31733         this_ptr_conv.is_owned = false;
31734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31735         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
31736 }
31737
31738 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) {
31739         LDKOpenChannel this_ptr_conv;
31740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31741         this_ptr_conv.is_owned = false;
31742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31743         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
31744         return ret_conv;
31745 }
31746
31747 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) {
31748         LDKOpenChannel this_ptr_conv;
31749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31750         this_ptr_conv.is_owned = false;
31751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31752         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
31753 }
31754
31755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31756         LDKOpenChannel this_ptr_conv;
31757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31758         this_ptr_conv.is_owned = false;
31759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31760         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
31761         return ret_conv;
31762 }
31763
31764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31765         LDKOpenChannel this_ptr_conv;
31766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31767         this_ptr_conv.is_owned = false;
31768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31769         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
31770 }
31771
31772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31773         LDKOpenChannel this_ptr_conv;
31774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31775         this_ptr_conv.is_owned = false;
31776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31777         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
31778         return ret_conv;
31779 }
31780
31781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31782         LDKOpenChannel this_ptr_conv;
31783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31784         this_ptr_conv.is_owned = false;
31785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31786         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
31787 }
31788
31789 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
31790         LDKOpenChannel this_ptr_conv;
31791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31792         this_ptr_conv.is_owned = false;
31793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31794         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
31795         return ret_conv;
31796 }
31797
31798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31799         LDKOpenChannel this_ptr_conv;
31800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31801         this_ptr_conv.is_owned = false;
31802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31803         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
31804 }
31805
31806 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
31807         LDKOpenChannel this_ptr_conv;
31808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31809         this_ptr_conv.is_owned = false;
31810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31811         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
31812         return ret_conv;
31813 }
31814
31815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31816         LDKOpenChannel this_ptr_conv;
31817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31818         this_ptr_conv.is_owned = false;
31819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31820         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
31821 }
31822
31823 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
31824         LDKOpenChannel this_ptr_conv;
31825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31826         this_ptr_conv.is_owned = false;
31827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31828         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
31829         return ret_conv;
31830 }
31831
31832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31833         LDKOpenChannel this_ptr_conv;
31834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31835         this_ptr_conv.is_owned = false;
31836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31837         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
31838 }
31839
31840 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31841         LDKOpenChannel this_ptr_conv;
31842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31843         this_ptr_conv.is_owned = false;
31844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31845         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31846         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
31847         return ret_arr;
31848 }
31849
31850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31851         LDKOpenChannel this_ptr_conv;
31852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31853         this_ptr_conv.is_owned = false;
31854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31855         LDKPublicKey val_ref;
31856         CHECK((*env)->GetArrayLength(env, val) == 33);
31857         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31858         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
31859 }
31860
31861 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31862         LDKOpenChannel this_ptr_conv;
31863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31864         this_ptr_conv.is_owned = false;
31865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31866         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31867         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
31868         return ret_arr;
31869 }
31870
31871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31872         LDKOpenChannel this_ptr_conv;
31873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31874         this_ptr_conv.is_owned = false;
31875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31876         LDKPublicKey val_ref;
31877         CHECK((*env)->GetArrayLength(env, val) == 33);
31878         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31879         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
31880 }
31881
31882 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31883         LDKOpenChannel this_ptr_conv;
31884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31885         this_ptr_conv.is_owned = false;
31886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31887         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31888         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
31889         return ret_arr;
31890 }
31891
31892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31893         LDKOpenChannel this_ptr_conv;
31894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31895         this_ptr_conv.is_owned = false;
31896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31897         LDKPublicKey val_ref;
31898         CHECK((*env)->GetArrayLength(env, val) == 33);
31899         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31900         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
31901 }
31902
31903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31904         LDKOpenChannel this_ptr_conv;
31905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31906         this_ptr_conv.is_owned = false;
31907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31908         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31909         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
31910         return ret_arr;
31911 }
31912
31913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31914         LDKOpenChannel this_ptr_conv;
31915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31916         this_ptr_conv.is_owned = false;
31917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31918         LDKPublicKey val_ref;
31919         CHECK((*env)->GetArrayLength(env, val) == 33);
31920         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31921         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
31922 }
31923
31924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31925         LDKOpenChannel this_ptr_conv;
31926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31927         this_ptr_conv.is_owned = false;
31928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31929         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31930         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
31931         return ret_arr;
31932 }
31933
31934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31935         LDKOpenChannel this_ptr_conv;
31936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31937         this_ptr_conv.is_owned = false;
31938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31939         LDKPublicKey val_ref;
31940         CHECK((*env)->GetArrayLength(env, val) == 33);
31941         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31942         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
31943 }
31944
31945 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31946         LDKOpenChannel this_ptr_conv;
31947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31948         this_ptr_conv.is_owned = false;
31949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31950         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31951         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
31952         return ret_arr;
31953 }
31954
31955 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) {
31956         LDKOpenChannel this_ptr_conv;
31957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31958         this_ptr_conv.is_owned = false;
31959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31960         LDKPublicKey val_ref;
31961         CHECK((*env)->GetArrayLength(env, val) == 33);
31962         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31963         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
31964 }
31965
31966 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
31967         LDKOpenChannel this_ptr_conv;
31968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31969         this_ptr_conv.is_owned = false;
31970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31971         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
31972         return ret_conv;
31973 }
31974
31975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
31976         LDKOpenChannel this_ptr_conv;
31977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31978         this_ptr_conv.is_owned = false;
31979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31980         OpenChannel_set_channel_flags(&this_ptr_conv, val);
31981 }
31982
31983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
31984         LDKOpenChannel this_ptr_conv;
31985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31986         this_ptr_conv.is_owned = false;
31987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31988         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
31989         int64_t ret_ref = 0;
31990         if ((uintptr_t)ret_var.inner > 4096) {
31991                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31992                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31994                 ret_ref = (uintptr_t)ret_var.inner;
31995                 if (ret_var.is_owned) {
31996                         ret_ref |= 1;
31997                 }
31998         }
31999         return ret_ref;
32000 }
32001
32002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32003         LDKOpenChannel this_ptr_conv;
32004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32005         this_ptr_conv.is_owned = false;
32006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32007         LDKChannelTypeFeatures val_conv;
32008         val_conv.inner = (void*)(val & (~1));
32009         val_conv.is_owned = (val & 1) || (val == 0);
32010         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32011         val_conv = ChannelTypeFeatures_clone(&val_conv);
32012         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
32013 }
32014
32015 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
32016         LDKOpenChannel ret_var = OpenChannel_clone(arg);
32017 int64_t ret_ref = 0;
32018 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32019 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32020 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32021 ret_ref = (uintptr_t)ret_var.inner;
32022 if (ret_var.is_owned) {
32023         ret_ref |= 1;
32024 }
32025         return ret_ref;
32026 }
32027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32028         LDKOpenChannel arg_conv;
32029         arg_conv.inner = (void*)(arg & (~1));
32030         arg_conv.is_owned = false;
32031         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32032         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
32033         return ret_conv;
32034 }
32035
32036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32037         LDKOpenChannel orig_conv;
32038         orig_conv.inner = (void*)(orig & (~1));
32039         orig_conv.is_owned = false;
32040         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32041         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
32042         int64_t ret_ref = 0;
32043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32046         ret_ref = (uintptr_t)ret_var.inner;
32047         if (ret_var.is_owned) {
32048                 ret_ref |= 1;
32049         }
32050         return ret_ref;
32051 }
32052
32053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32054         LDKAcceptChannel this_obj_conv;
32055         this_obj_conv.inner = (void*)(this_obj & (~1));
32056         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32058         AcceptChannel_free(this_obj_conv);
32059 }
32060
32061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32062         LDKAcceptChannel this_ptr_conv;
32063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32064         this_ptr_conv.is_owned = false;
32065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32066         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32067         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
32068         return ret_arr;
32069 }
32070
32071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32072         LDKAcceptChannel this_ptr_conv;
32073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32074         this_ptr_conv.is_owned = false;
32075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32076         LDKThirtyTwoBytes val_ref;
32077         CHECK((*env)->GetArrayLength(env, val) == 32);
32078         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32079         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
32080 }
32081
32082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32083         LDKAcceptChannel this_ptr_conv;
32084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32085         this_ptr_conv.is_owned = false;
32086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32087         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
32088         return ret_conv;
32089 }
32090
32091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32092         LDKAcceptChannel this_ptr_conv;
32093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32094         this_ptr_conv.is_owned = false;
32095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32096         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
32097 }
32098
32099 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) {
32100         LDKAcceptChannel this_ptr_conv;
32101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32102         this_ptr_conv.is_owned = false;
32103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32104         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
32105         return ret_conv;
32106 }
32107
32108 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) {
32109         LDKAcceptChannel this_ptr_conv;
32110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32111         this_ptr_conv.is_owned = false;
32112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32113         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
32114 }
32115
32116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32117         LDKAcceptChannel this_ptr_conv;
32118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32119         this_ptr_conv.is_owned = false;
32120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32121         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
32122         return ret_conv;
32123 }
32124
32125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32126         LDKAcceptChannel this_ptr_conv;
32127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32128         this_ptr_conv.is_owned = false;
32129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32130         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
32131 }
32132
32133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32134         LDKAcceptChannel this_ptr_conv;
32135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32136         this_ptr_conv.is_owned = false;
32137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32138         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
32139         return ret_conv;
32140 }
32141
32142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32143         LDKAcceptChannel this_ptr_conv;
32144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32145         this_ptr_conv.is_owned = false;
32146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32147         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
32148 }
32149
32150 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
32151         LDKAcceptChannel this_ptr_conv;
32152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32153         this_ptr_conv.is_owned = false;
32154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32155         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
32156         return ret_conv;
32157 }
32158
32159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32160         LDKAcceptChannel this_ptr_conv;
32161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32162         this_ptr_conv.is_owned = false;
32163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32164         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
32165 }
32166
32167 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32168         LDKAcceptChannel this_ptr_conv;
32169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32170         this_ptr_conv.is_owned = false;
32171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32172         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
32173         return ret_conv;
32174 }
32175
32176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32177         LDKAcceptChannel this_ptr_conv;
32178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32179         this_ptr_conv.is_owned = false;
32180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32181         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
32182 }
32183
32184 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32185         LDKAcceptChannel this_ptr_conv;
32186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32187         this_ptr_conv.is_owned = false;
32188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32189         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
32190         return ret_conv;
32191 }
32192
32193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32194         LDKAcceptChannel this_ptr_conv;
32195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32196         this_ptr_conv.is_owned = false;
32197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32198         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
32199 }
32200
32201 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32202         LDKAcceptChannel this_ptr_conv;
32203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32204         this_ptr_conv.is_owned = false;
32205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32206         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32207         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
32208         return ret_arr;
32209 }
32210
32211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32212         LDKAcceptChannel this_ptr_conv;
32213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32214         this_ptr_conv.is_owned = false;
32215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32216         LDKPublicKey val_ref;
32217         CHECK((*env)->GetArrayLength(env, val) == 33);
32218         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32219         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
32220 }
32221
32222 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32223         LDKAcceptChannel this_ptr_conv;
32224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32225         this_ptr_conv.is_owned = false;
32226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32227         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32228         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32229         return ret_arr;
32230 }
32231
32232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32233         LDKAcceptChannel this_ptr_conv;
32234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32235         this_ptr_conv.is_owned = false;
32236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32237         LDKPublicKey val_ref;
32238         CHECK((*env)->GetArrayLength(env, val) == 33);
32239         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32240         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
32241 }
32242
32243 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32244         LDKAcceptChannel this_ptr_conv;
32245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32246         this_ptr_conv.is_owned = false;
32247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32248         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32249         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
32250         return ret_arr;
32251 }
32252
32253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32254         LDKAcceptChannel this_ptr_conv;
32255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32256         this_ptr_conv.is_owned = false;
32257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32258         LDKPublicKey val_ref;
32259         CHECK((*env)->GetArrayLength(env, val) == 33);
32260         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32261         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
32262 }
32263
32264 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32265         LDKAcceptChannel this_ptr_conv;
32266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32267         this_ptr_conv.is_owned = false;
32268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32269         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32270         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32271         return ret_arr;
32272 }
32273
32274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32275         LDKAcceptChannel this_ptr_conv;
32276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32277         this_ptr_conv.is_owned = false;
32278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32279         LDKPublicKey val_ref;
32280         CHECK((*env)->GetArrayLength(env, val) == 33);
32281         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32282         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32283 }
32284
32285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32286         LDKAcceptChannel this_ptr_conv;
32287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32288         this_ptr_conv.is_owned = false;
32289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32290         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32291         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
32292         return ret_arr;
32293 }
32294
32295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32296         LDKAcceptChannel this_ptr_conv;
32297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32298         this_ptr_conv.is_owned = false;
32299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32300         LDKPublicKey val_ref;
32301         CHECK((*env)->GetArrayLength(env, val) == 33);
32302         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32303         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
32304 }
32305
32306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32307         LDKAcceptChannel this_ptr_conv;
32308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32309         this_ptr_conv.is_owned = false;
32310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32311         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32312         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
32313         return ret_arr;
32314 }
32315
32316 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) {
32317         LDKAcceptChannel this_ptr_conv;
32318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32319         this_ptr_conv.is_owned = false;
32320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32321         LDKPublicKey val_ref;
32322         CHECK((*env)->GetArrayLength(env, val) == 33);
32323         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32324         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
32325 }
32326
32327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
32328         LDKAcceptChannel this_ptr_conv;
32329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32330         this_ptr_conv.is_owned = false;
32331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32332         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
32333         int64_t ret_ref = 0;
32334         if ((uintptr_t)ret_var.inner > 4096) {
32335                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32336                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32338                 ret_ref = (uintptr_t)ret_var.inner;
32339                 if (ret_var.is_owned) {
32340                         ret_ref |= 1;
32341                 }
32342         }
32343         return ret_ref;
32344 }
32345
32346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32347         LDKAcceptChannel this_ptr_conv;
32348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32349         this_ptr_conv.is_owned = false;
32350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32351         LDKChannelTypeFeatures val_conv;
32352         val_conv.inner = (void*)(val & (~1));
32353         val_conv.is_owned = (val & 1) || (val == 0);
32354         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32355         val_conv = ChannelTypeFeatures_clone(&val_conv);
32356         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
32357 }
32358
32359 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
32360         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
32361 int64_t ret_ref = 0;
32362 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32363 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32364 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32365 ret_ref = (uintptr_t)ret_var.inner;
32366 if (ret_var.is_owned) {
32367         ret_ref |= 1;
32368 }
32369         return ret_ref;
32370 }
32371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32372         LDKAcceptChannel arg_conv;
32373         arg_conv.inner = (void*)(arg & (~1));
32374         arg_conv.is_owned = false;
32375         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32376         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
32377         return ret_conv;
32378 }
32379
32380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32381         LDKAcceptChannel orig_conv;
32382         orig_conv.inner = (void*)(orig & (~1));
32383         orig_conv.is_owned = false;
32384         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32385         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
32386         int64_t ret_ref = 0;
32387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32390         ret_ref = (uintptr_t)ret_var.inner;
32391         if (ret_var.is_owned) {
32392                 ret_ref |= 1;
32393         }
32394         return ret_ref;
32395 }
32396
32397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32398         LDKFundingCreated this_obj_conv;
32399         this_obj_conv.inner = (void*)(this_obj & (~1));
32400         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32402         FundingCreated_free(this_obj_conv);
32403 }
32404
32405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32406         LDKFundingCreated this_ptr_conv;
32407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32408         this_ptr_conv.is_owned = false;
32409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32410         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32411         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
32412         return ret_arr;
32413 }
32414
32415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32416         LDKFundingCreated this_ptr_conv;
32417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32418         this_ptr_conv.is_owned = false;
32419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32420         LDKThirtyTwoBytes val_ref;
32421         CHECK((*env)->GetArrayLength(env, val) == 32);
32422         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32423         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
32424 }
32425
32426 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
32427         LDKFundingCreated this_ptr_conv;
32428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32429         this_ptr_conv.is_owned = false;
32430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32431         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32432         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
32433         return ret_arr;
32434 }
32435
32436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32437         LDKFundingCreated this_ptr_conv;
32438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32439         this_ptr_conv.is_owned = false;
32440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32441         LDKThirtyTwoBytes val_ref;
32442         CHECK((*env)->GetArrayLength(env, val) == 32);
32443         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32444         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
32445 }
32446
32447 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
32448         LDKFundingCreated this_ptr_conv;
32449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32450         this_ptr_conv.is_owned = false;
32451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32452         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
32453         return ret_conv;
32454 }
32455
32456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32457         LDKFundingCreated this_ptr_conv;
32458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32459         this_ptr_conv.is_owned = false;
32460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32461         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
32462 }
32463
32464 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32465         LDKFundingCreated this_ptr_conv;
32466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32467         this_ptr_conv.is_owned = false;
32468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32469         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32470         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
32471         return ret_arr;
32472 }
32473
32474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32475         LDKFundingCreated this_ptr_conv;
32476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32477         this_ptr_conv.is_owned = false;
32478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32479         LDKSignature val_ref;
32480         CHECK((*env)->GetArrayLength(env, val) == 64);
32481         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32482         FundingCreated_set_signature(&this_ptr_conv, val_ref);
32483 }
32484
32485 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) {
32486         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
32487         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
32488         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
32489         LDKThirtyTwoBytes funding_txid_arg_ref;
32490         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
32491         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
32492         LDKSignature signature_arg_ref;
32493         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32494         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32495         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
32496         int64_t ret_ref = 0;
32497         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32498         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32500         ret_ref = (uintptr_t)ret_var.inner;
32501         if (ret_var.is_owned) {
32502                 ret_ref |= 1;
32503         }
32504         return ret_ref;
32505 }
32506
32507 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
32508         LDKFundingCreated ret_var = FundingCreated_clone(arg);
32509 int64_t ret_ref = 0;
32510 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32511 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32512 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32513 ret_ref = (uintptr_t)ret_var.inner;
32514 if (ret_var.is_owned) {
32515         ret_ref |= 1;
32516 }
32517         return ret_ref;
32518 }
32519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32520         LDKFundingCreated arg_conv;
32521         arg_conv.inner = (void*)(arg & (~1));
32522         arg_conv.is_owned = false;
32523         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32524         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
32525         return ret_conv;
32526 }
32527
32528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32529         LDKFundingCreated orig_conv;
32530         orig_conv.inner = (void*)(orig & (~1));
32531         orig_conv.is_owned = false;
32532         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32533         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
32534         int64_t ret_ref = 0;
32535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32538         ret_ref = (uintptr_t)ret_var.inner;
32539         if (ret_var.is_owned) {
32540                 ret_ref |= 1;
32541         }
32542         return ret_ref;
32543 }
32544
32545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32546         LDKFundingSigned this_obj_conv;
32547         this_obj_conv.inner = (void*)(this_obj & (~1));
32548         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32550         FundingSigned_free(this_obj_conv);
32551 }
32552
32553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32554         LDKFundingSigned this_ptr_conv;
32555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32556         this_ptr_conv.is_owned = false;
32557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32558         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32559         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
32560         return ret_arr;
32561 }
32562
32563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32564         LDKFundingSigned this_ptr_conv;
32565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32566         this_ptr_conv.is_owned = false;
32567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32568         LDKThirtyTwoBytes val_ref;
32569         CHECK((*env)->GetArrayLength(env, val) == 32);
32570         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32571         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
32572 }
32573
32574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32575         LDKFundingSigned this_ptr_conv;
32576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32577         this_ptr_conv.is_owned = false;
32578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32579         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32580         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
32581         return ret_arr;
32582 }
32583
32584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32585         LDKFundingSigned this_ptr_conv;
32586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32587         this_ptr_conv.is_owned = false;
32588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32589         LDKSignature val_ref;
32590         CHECK((*env)->GetArrayLength(env, val) == 64);
32591         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32592         FundingSigned_set_signature(&this_ptr_conv, val_ref);
32593 }
32594
32595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
32596         LDKThirtyTwoBytes channel_id_arg_ref;
32597         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32598         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32599         LDKSignature signature_arg_ref;
32600         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32601         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32602         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
32603         int64_t ret_ref = 0;
32604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32607         ret_ref = (uintptr_t)ret_var.inner;
32608         if (ret_var.is_owned) {
32609                 ret_ref |= 1;
32610         }
32611         return ret_ref;
32612 }
32613
32614 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
32615         LDKFundingSigned ret_var = FundingSigned_clone(arg);
32616 int64_t ret_ref = 0;
32617 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32618 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32619 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32620 ret_ref = (uintptr_t)ret_var.inner;
32621 if (ret_var.is_owned) {
32622         ret_ref |= 1;
32623 }
32624         return ret_ref;
32625 }
32626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32627         LDKFundingSigned arg_conv;
32628         arg_conv.inner = (void*)(arg & (~1));
32629         arg_conv.is_owned = false;
32630         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32631         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
32632         return ret_conv;
32633 }
32634
32635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32636         LDKFundingSigned orig_conv;
32637         orig_conv.inner = (void*)(orig & (~1));
32638         orig_conv.is_owned = false;
32639         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32640         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
32641         int64_t ret_ref = 0;
32642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32645         ret_ref = (uintptr_t)ret_var.inner;
32646         if (ret_var.is_owned) {
32647                 ret_ref |= 1;
32648         }
32649         return ret_ref;
32650 }
32651
32652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32653         LDKChannelReady this_obj_conv;
32654         this_obj_conv.inner = (void*)(this_obj & (~1));
32655         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32657         ChannelReady_free(this_obj_conv);
32658 }
32659
32660 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32661         LDKChannelReady this_ptr_conv;
32662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32663         this_ptr_conv.is_owned = false;
32664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32665         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32666         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
32667         return ret_arr;
32668 }
32669
32670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32671         LDKChannelReady this_ptr_conv;
32672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32673         this_ptr_conv.is_owned = false;
32674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32675         LDKThirtyTwoBytes val_ref;
32676         CHECK((*env)->GetArrayLength(env, val) == 32);
32677         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32678         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
32679 }
32680
32681 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32682         LDKChannelReady this_ptr_conv;
32683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32684         this_ptr_conv.is_owned = false;
32685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32686         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32687         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
32688         return ret_arr;
32689 }
32690
32691 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) {
32692         LDKChannelReady this_ptr_conv;
32693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32694         this_ptr_conv.is_owned = false;
32695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32696         LDKPublicKey val_ref;
32697         CHECK((*env)->GetArrayLength(env, val) == 33);
32698         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32699         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
32700 }
32701
32702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
32703         LDKChannelReady this_ptr_conv;
32704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32705         this_ptr_conv.is_owned = false;
32706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32707         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32708         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
32709         int64_t ret_ref = (uintptr_t)ret_copy;
32710         return ret_ref;
32711 }
32712
32713 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) {
32714         LDKChannelReady this_ptr_conv;
32715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32716         this_ptr_conv.is_owned = false;
32717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32718         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32719         CHECK_ACCESS(val_ptr);
32720         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32721         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
32722         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
32723 }
32724
32725 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) {
32726         LDKThirtyTwoBytes channel_id_arg_ref;
32727         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32728         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32729         LDKPublicKey next_per_commitment_point_arg_ref;
32730         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
32731         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
32732         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
32733         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
32734         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
32735         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
32736         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
32737         int64_t ret_ref = 0;
32738         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32739         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32741         ret_ref = (uintptr_t)ret_var.inner;
32742         if (ret_var.is_owned) {
32743                 ret_ref |= 1;
32744         }
32745         return ret_ref;
32746 }
32747
32748 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
32749         LDKChannelReady ret_var = ChannelReady_clone(arg);
32750 int64_t ret_ref = 0;
32751 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32752 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32753 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32754 ret_ref = (uintptr_t)ret_var.inner;
32755 if (ret_var.is_owned) {
32756         ret_ref |= 1;
32757 }
32758         return ret_ref;
32759 }
32760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32761         LDKChannelReady arg_conv;
32762         arg_conv.inner = (void*)(arg & (~1));
32763         arg_conv.is_owned = false;
32764         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32765         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
32766         return ret_conv;
32767 }
32768
32769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32770         LDKChannelReady orig_conv;
32771         orig_conv.inner = (void*)(orig & (~1));
32772         orig_conv.is_owned = false;
32773         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32774         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
32775         int64_t ret_ref = 0;
32776         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32777         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32779         ret_ref = (uintptr_t)ret_var.inner;
32780         if (ret_var.is_owned) {
32781                 ret_ref |= 1;
32782         }
32783         return ret_ref;
32784 }
32785
32786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32787         LDKShutdown this_obj_conv;
32788         this_obj_conv.inner = (void*)(this_obj & (~1));
32789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32791         Shutdown_free(this_obj_conv);
32792 }
32793
32794 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32795         LDKShutdown this_ptr_conv;
32796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32797         this_ptr_conv.is_owned = false;
32798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32799         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32800         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
32801         return ret_arr;
32802 }
32803
32804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32805         LDKShutdown this_ptr_conv;
32806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32807         this_ptr_conv.is_owned = false;
32808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32809         LDKThirtyTwoBytes val_ref;
32810         CHECK((*env)->GetArrayLength(env, val) == 32);
32811         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32812         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
32813 }
32814
32815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32816         LDKShutdown 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         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
32821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32823         return ret_arr;
32824 }
32825
32826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32827         LDKShutdown this_ptr_conv;
32828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32829         this_ptr_conv.is_owned = false;
32830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32831         LDKCVec_u8Z val_ref;
32832         val_ref.datalen = (*env)->GetArrayLength(env, val);
32833         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
32834         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
32835         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
32836 }
32837
32838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
32839         LDKThirtyTwoBytes channel_id_arg_ref;
32840         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32841         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32842         LDKCVec_u8Z scriptpubkey_arg_ref;
32843         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
32844         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
32845         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
32846         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
32847         int64_t ret_ref = 0;
32848         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32849         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32851         ret_ref = (uintptr_t)ret_var.inner;
32852         if (ret_var.is_owned) {
32853                 ret_ref |= 1;
32854         }
32855         return ret_ref;
32856 }
32857
32858 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
32859         LDKShutdown ret_var = Shutdown_clone(arg);
32860 int64_t ret_ref = 0;
32861 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32862 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32863 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32864 ret_ref = (uintptr_t)ret_var.inner;
32865 if (ret_var.is_owned) {
32866         ret_ref |= 1;
32867 }
32868         return ret_ref;
32869 }
32870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32871         LDKShutdown arg_conv;
32872         arg_conv.inner = (void*)(arg & (~1));
32873         arg_conv.is_owned = false;
32874         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32875         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
32876         return ret_conv;
32877 }
32878
32879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32880         LDKShutdown orig_conv;
32881         orig_conv.inner = (void*)(orig & (~1));
32882         orig_conv.is_owned = false;
32883         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32884         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
32885         int64_t ret_ref = 0;
32886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32889         ret_ref = (uintptr_t)ret_var.inner;
32890         if (ret_var.is_owned) {
32891                 ret_ref |= 1;
32892         }
32893         return ret_ref;
32894 }
32895
32896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32897         LDKClosingSignedFeeRange this_obj_conv;
32898         this_obj_conv.inner = (void*)(this_obj & (~1));
32899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32901         ClosingSignedFeeRange_free(this_obj_conv);
32902 }
32903
32904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32905         LDKClosingSignedFeeRange this_ptr_conv;
32906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32907         this_ptr_conv.is_owned = false;
32908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32909         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
32910         return ret_conv;
32911 }
32912
32913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32914         LDKClosingSignedFeeRange this_ptr_conv;
32915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32916         this_ptr_conv.is_owned = false;
32917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32918         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
32919 }
32920
32921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32922         LDKClosingSignedFeeRange this_ptr_conv;
32923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32924         this_ptr_conv.is_owned = false;
32925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32926         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
32927         return ret_conv;
32928 }
32929
32930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32931         LDKClosingSignedFeeRange this_ptr_conv;
32932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32933         this_ptr_conv.is_owned = false;
32934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32935         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
32936 }
32937
32938 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) {
32939         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
32940         int64_t ret_ref = 0;
32941         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32942         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32944         ret_ref = (uintptr_t)ret_var.inner;
32945         if (ret_var.is_owned) {
32946                 ret_ref |= 1;
32947         }
32948         return ret_ref;
32949 }
32950
32951 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
32952         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
32953 int64_t ret_ref = 0;
32954 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32955 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32956 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32957 ret_ref = (uintptr_t)ret_var.inner;
32958 if (ret_var.is_owned) {
32959         ret_ref |= 1;
32960 }
32961         return ret_ref;
32962 }
32963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32964         LDKClosingSignedFeeRange arg_conv;
32965         arg_conv.inner = (void*)(arg & (~1));
32966         arg_conv.is_owned = false;
32967         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32968         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
32969         return ret_conv;
32970 }
32971
32972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32973         LDKClosingSignedFeeRange orig_conv;
32974         orig_conv.inner = (void*)(orig & (~1));
32975         orig_conv.is_owned = false;
32976         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32977         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
32978         int64_t ret_ref = 0;
32979         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32980         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32982         ret_ref = (uintptr_t)ret_var.inner;
32983         if (ret_var.is_owned) {
32984                 ret_ref |= 1;
32985         }
32986         return ret_ref;
32987 }
32988
32989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32990         LDKClosingSigned this_obj_conv;
32991         this_obj_conv.inner = (void*)(this_obj & (~1));
32992         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32994         ClosingSigned_free(this_obj_conv);
32995 }
32996
32997 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32998         LDKClosingSigned this_ptr_conv;
32999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33000         this_ptr_conv.is_owned = false;
33001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33002         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33003         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
33004         return ret_arr;
33005 }
33006
33007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33008         LDKClosingSigned this_ptr_conv;
33009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33010         this_ptr_conv.is_owned = false;
33011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33012         LDKThirtyTwoBytes val_ref;
33013         CHECK((*env)->GetArrayLength(env, val) == 32);
33014         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33015         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
33016 }
33017
33018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33019         LDKClosingSigned this_ptr_conv;
33020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33021         this_ptr_conv.is_owned = false;
33022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33023         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
33024         return ret_conv;
33025 }
33026
33027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33028         LDKClosingSigned this_ptr_conv;
33029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33030         this_ptr_conv.is_owned = false;
33031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33032         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
33033 }
33034
33035 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33036         LDKClosingSigned this_ptr_conv;
33037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33038         this_ptr_conv.is_owned = false;
33039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33040         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33041         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
33042         return ret_arr;
33043 }
33044
33045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33046         LDKClosingSigned this_ptr_conv;
33047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33048         this_ptr_conv.is_owned = false;
33049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33050         LDKSignature val_ref;
33051         CHECK((*env)->GetArrayLength(env, val) == 64);
33052         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33053         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
33054 }
33055
33056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
33057         LDKClosingSigned this_ptr_conv;
33058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33059         this_ptr_conv.is_owned = false;
33060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33061         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
33062         int64_t ret_ref = 0;
33063         if ((uintptr_t)ret_var.inner > 4096) {
33064                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33065                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33067                 ret_ref = (uintptr_t)ret_var.inner;
33068                 if (ret_var.is_owned) {
33069                         ret_ref |= 1;
33070                 }
33071         }
33072         return ret_ref;
33073 }
33074
33075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33076         LDKClosingSigned this_ptr_conv;
33077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33078         this_ptr_conv.is_owned = false;
33079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33080         LDKClosingSignedFeeRange val_conv;
33081         val_conv.inner = (void*)(val & (~1));
33082         val_conv.is_owned = (val & 1) || (val == 0);
33083         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33084         val_conv = ClosingSignedFeeRange_clone(&val_conv);
33085         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
33086 }
33087
33088 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) {
33089         LDKThirtyTwoBytes channel_id_arg_ref;
33090         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33091         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33092         LDKSignature signature_arg_ref;
33093         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33094         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33095         LDKClosingSignedFeeRange fee_range_arg_conv;
33096         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
33097         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
33098         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
33099         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
33100         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
33101         int64_t ret_ref = 0;
33102         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33103         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33105         ret_ref = (uintptr_t)ret_var.inner;
33106         if (ret_var.is_owned) {
33107                 ret_ref |= 1;
33108         }
33109         return ret_ref;
33110 }
33111
33112 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
33113         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
33114 int64_t ret_ref = 0;
33115 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33116 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33117 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33118 ret_ref = (uintptr_t)ret_var.inner;
33119 if (ret_var.is_owned) {
33120         ret_ref |= 1;
33121 }
33122         return ret_ref;
33123 }
33124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33125         LDKClosingSigned arg_conv;
33126         arg_conv.inner = (void*)(arg & (~1));
33127         arg_conv.is_owned = false;
33128         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33129         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
33130         return ret_conv;
33131 }
33132
33133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33134         LDKClosingSigned orig_conv;
33135         orig_conv.inner = (void*)(orig & (~1));
33136         orig_conv.is_owned = false;
33137         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33138         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
33139         int64_t ret_ref = 0;
33140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33143         ret_ref = (uintptr_t)ret_var.inner;
33144         if (ret_var.is_owned) {
33145                 ret_ref |= 1;
33146         }
33147         return ret_ref;
33148 }
33149
33150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33151         LDKUpdateAddHTLC this_obj_conv;
33152         this_obj_conv.inner = (void*)(this_obj & (~1));
33153         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33155         UpdateAddHTLC_free(this_obj_conv);
33156 }
33157
33158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33159         LDKUpdateAddHTLC this_ptr_conv;
33160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33161         this_ptr_conv.is_owned = false;
33162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33163         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33164         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
33165         return ret_arr;
33166 }
33167
33168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33169         LDKUpdateAddHTLC this_ptr_conv;
33170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33171         this_ptr_conv.is_owned = false;
33172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33173         LDKThirtyTwoBytes val_ref;
33174         CHECK((*env)->GetArrayLength(env, val) == 32);
33175         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33176         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
33177 }
33178
33179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33180         LDKUpdateAddHTLC this_ptr_conv;
33181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33182         this_ptr_conv.is_owned = false;
33183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33184         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
33185         return ret_conv;
33186 }
33187
33188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33189         LDKUpdateAddHTLC this_ptr_conv;
33190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33191         this_ptr_conv.is_owned = false;
33192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33193         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
33194 }
33195
33196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33197         LDKUpdateAddHTLC this_ptr_conv;
33198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33199         this_ptr_conv.is_owned = false;
33200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33201         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
33202         return ret_conv;
33203 }
33204
33205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33206         LDKUpdateAddHTLC this_ptr_conv;
33207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33208         this_ptr_conv.is_owned = false;
33209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33210         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
33211 }
33212
33213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33214         LDKUpdateAddHTLC this_ptr_conv;
33215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33216         this_ptr_conv.is_owned = false;
33217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33218         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33219         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
33220         return ret_arr;
33221 }
33222
33223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33224         LDKUpdateAddHTLC this_ptr_conv;
33225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33226         this_ptr_conv.is_owned = false;
33227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33228         LDKThirtyTwoBytes val_ref;
33229         CHECK((*env)->GetArrayLength(env, val) == 32);
33230         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33231         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
33232 }
33233
33234 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
33235         LDKUpdateAddHTLC this_ptr_conv;
33236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33237         this_ptr_conv.is_owned = false;
33238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33239         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
33240         return ret_conv;
33241 }
33242
33243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33244         LDKUpdateAddHTLC 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         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
33249 }
33250
33251 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
33252         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
33253 int64_t ret_ref = 0;
33254 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33255 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33256 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33257 ret_ref = (uintptr_t)ret_var.inner;
33258 if (ret_var.is_owned) {
33259         ret_ref |= 1;
33260 }
33261         return ret_ref;
33262 }
33263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33264         LDKUpdateAddHTLC arg_conv;
33265         arg_conv.inner = (void*)(arg & (~1));
33266         arg_conv.is_owned = false;
33267         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33268         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
33269         return ret_conv;
33270 }
33271
33272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33273         LDKUpdateAddHTLC orig_conv;
33274         orig_conv.inner = (void*)(orig & (~1));
33275         orig_conv.is_owned = false;
33276         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33277         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
33278         int64_t ret_ref = 0;
33279         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33280         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33282         ret_ref = (uintptr_t)ret_var.inner;
33283         if (ret_var.is_owned) {
33284                 ret_ref |= 1;
33285         }
33286         return ret_ref;
33287 }
33288
33289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33290         LDKUpdateFulfillHTLC this_obj_conv;
33291         this_obj_conv.inner = (void*)(this_obj & (~1));
33292         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33294         UpdateFulfillHTLC_free(this_obj_conv);
33295 }
33296
33297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33298         LDKUpdateFulfillHTLC this_ptr_conv;
33299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33300         this_ptr_conv.is_owned = false;
33301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33302         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33303         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
33304         return ret_arr;
33305 }
33306
33307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33308         LDKUpdateFulfillHTLC this_ptr_conv;
33309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33310         this_ptr_conv.is_owned = false;
33311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33312         LDKThirtyTwoBytes val_ref;
33313         CHECK((*env)->GetArrayLength(env, val) == 32);
33314         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33315         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
33316 }
33317
33318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33319         LDKUpdateFulfillHTLC this_ptr_conv;
33320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33321         this_ptr_conv.is_owned = false;
33322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33323         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
33324         return ret_conv;
33325 }
33326
33327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33328         LDKUpdateFulfillHTLC this_ptr_conv;
33329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33330         this_ptr_conv.is_owned = false;
33331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33332         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
33333 }
33334
33335 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
33336         LDKUpdateFulfillHTLC this_ptr_conv;
33337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33338         this_ptr_conv.is_owned = false;
33339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33340         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33341         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
33342         return ret_arr;
33343 }
33344
33345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33346         LDKUpdateFulfillHTLC this_ptr_conv;
33347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33348         this_ptr_conv.is_owned = false;
33349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33350         LDKThirtyTwoBytes val_ref;
33351         CHECK((*env)->GetArrayLength(env, val) == 32);
33352         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33353         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
33354 }
33355
33356 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) {
33357         LDKThirtyTwoBytes channel_id_arg_ref;
33358         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33359         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33360         LDKThirtyTwoBytes payment_preimage_arg_ref;
33361         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
33362         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
33363         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
33364         int64_t ret_ref = 0;
33365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33368         ret_ref = (uintptr_t)ret_var.inner;
33369         if (ret_var.is_owned) {
33370                 ret_ref |= 1;
33371         }
33372         return ret_ref;
33373 }
33374
33375 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
33376         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
33377 int64_t ret_ref = 0;
33378 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33379 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33380 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33381 ret_ref = (uintptr_t)ret_var.inner;
33382 if (ret_var.is_owned) {
33383         ret_ref |= 1;
33384 }
33385         return ret_ref;
33386 }
33387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33388         LDKUpdateFulfillHTLC arg_conv;
33389         arg_conv.inner = (void*)(arg & (~1));
33390         arg_conv.is_owned = false;
33391         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33392         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
33393         return ret_conv;
33394 }
33395
33396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33397         LDKUpdateFulfillHTLC orig_conv;
33398         orig_conv.inner = (void*)(orig & (~1));
33399         orig_conv.is_owned = false;
33400         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33401         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
33402         int64_t ret_ref = 0;
33403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33406         ret_ref = (uintptr_t)ret_var.inner;
33407         if (ret_var.is_owned) {
33408                 ret_ref |= 1;
33409         }
33410         return ret_ref;
33411 }
33412
33413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33414         LDKUpdateFailHTLC this_obj_conv;
33415         this_obj_conv.inner = (void*)(this_obj & (~1));
33416         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33418         UpdateFailHTLC_free(this_obj_conv);
33419 }
33420
33421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33422         LDKUpdateFailHTLC this_ptr_conv;
33423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33424         this_ptr_conv.is_owned = false;
33425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33426         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33427         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
33428         return ret_arr;
33429 }
33430
33431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33432         LDKUpdateFailHTLC this_ptr_conv;
33433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33434         this_ptr_conv.is_owned = false;
33435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33436         LDKThirtyTwoBytes val_ref;
33437         CHECK((*env)->GetArrayLength(env, val) == 32);
33438         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33439         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
33440 }
33441
33442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33443         LDKUpdateFailHTLC this_ptr_conv;
33444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33445         this_ptr_conv.is_owned = false;
33446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33447         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
33448         return ret_conv;
33449 }
33450
33451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33452         LDKUpdateFailHTLC this_ptr_conv;
33453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33454         this_ptr_conv.is_owned = false;
33455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33456         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
33457 }
33458
33459 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
33460         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
33461 int64_t ret_ref = 0;
33462 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33463 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33464 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33465 ret_ref = (uintptr_t)ret_var.inner;
33466 if (ret_var.is_owned) {
33467         ret_ref |= 1;
33468 }
33469         return ret_ref;
33470 }
33471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33472         LDKUpdateFailHTLC arg_conv;
33473         arg_conv.inner = (void*)(arg & (~1));
33474         arg_conv.is_owned = false;
33475         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33476         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
33477         return ret_conv;
33478 }
33479
33480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33481         LDKUpdateFailHTLC orig_conv;
33482         orig_conv.inner = (void*)(orig & (~1));
33483         orig_conv.is_owned = false;
33484         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33485         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
33486         int64_t ret_ref = 0;
33487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33490         ret_ref = (uintptr_t)ret_var.inner;
33491         if (ret_var.is_owned) {
33492                 ret_ref |= 1;
33493         }
33494         return ret_ref;
33495 }
33496
33497 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33498         LDKUpdateFailMalformedHTLC this_obj_conv;
33499         this_obj_conv.inner = (void*)(this_obj & (~1));
33500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33502         UpdateFailMalformedHTLC_free(this_obj_conv);
33503 }
33504
33505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33506         LDKUpdateFailMalformedHTLC 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33511         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
33512         return ret_arr;
33513 }
33514
33515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33516         LDKUpdateFailMalformedHTLC this_ptr_conv;
33517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33518         this_ptr_conv.is_owned = false;
33519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33520         LDKThirtyTwoBytes val_ref;
33521         CHECK((*env)->GetArrayLength(env, val) == 32);
33522         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33523         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
33524 }
33525
33526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33527         LDKUpdateFailMalformedHTLC this_ptr_conv;
33528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33529         this_ptr_conv.is_owned = false;
33530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33531         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
33532         return ret_conv;
33533 }
33534
33535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33536         LDKUpdateFailMalformedHTLC this_ptr_conv;
33537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33538         this_ptr_conv.is_owned = false;
33539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33540         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
33541 }
33542
33543 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
33544         LDKUpdateFailMalformedHTLC this_ptr_conv;
33545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33546         this_ptr_conv.is_owned = false;
33547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33548         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
33549         return ret_conv;
33550 }
33551
33552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33553         LDKUpdateFailMalformedHTLC this_ptr_conv;
33554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33555         this_ptr_conv.is_owned = false;
33556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33557         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
33558 }
33559
33560 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
33561         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
33562 int64_t ret_ref = 0;
33563 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33564 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33565 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33566 ret_ref = (uintptr_t)ret_var.inner;
33567 if (ret_var.is_owned) {
33568         ret_ref |= 1;
33569 }
33570         return ret_ref;
33571 }
33572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33573         LDKUpdateFailMalformedHTLC arg_conv;
33574         arg_conv.inner = (void*)(arg & (~1));
33575         arg_conv.is_owned = false;
33576         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33577         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
33578         return ret_conv;
33579 }
33580
33581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33582         LDKUpdateFailMalformedHTLC orig_conv;
33583         orig_conv.inner = (void*)(orig & (~1));
33584         orig_conv.is_owned = false;
33585         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33586         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
33587         int64_t ret_ref = 0;
33588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33591         ret_ref = (uintptr_t)ret_var.inner;
33592         if (ret_var.is_owned) {
33593                 ret_ref |= 1;
33594         }
33595         return ret_ref;
33596 }
33597
33598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33599         LDKCommitmentSigned this_obj_conv;
33600         this_obj_conv.inner = (void*)(this_obj & (~1));
33601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33603         CommitmentSigned_free(this_obj_conv);
33604 }
33605
33606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33607         LDKCommitmentSigned this_ptr_conv;
33608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33609         this_ptr_conv.is_owned = false;
33610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33611         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33612         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
33613         return ret_arr;
33614 }
33615
33616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33617         LDKCommitmentSigned this_ptr_conv;
33618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33619         this_ptr_conv.is_owned = false;
33620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33621         LDKThirtyTwoBytes val_ref;
33622         CHECK((*env)->GetArrayLength(env, val) == 32);
33623         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33624         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
33625 }
33626
33627 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33628         LDKCommitmentSigned this_ptr_conv;
33629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33630         this_ptr_conv.is_owned = false;
33631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33632         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33633         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
33634         return ret_arr;
33635 }
33636
33637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33638         LDKCommitmentSigned this_ptr_conv;
33639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33640         this_ptr_conv.is_owned = false;
33641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33642         LDKSignature val_ref;
33643         CHECK((*env)->GetArrayLength(env, val) == 64);
33644         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33645         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
33646 }
33647
33648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
33649         LDKCommitmentSigned this_ptr_conv;
33650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33651         this_ptr_conv.is_owned = false;
33652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33653         LDKCVec_SignatureZ val_constr;
33654         val_constr.datalen = (*env)->GetArrayLength(env, val);
33655         if (val_constr.datalen > 0)
33656                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33657         else
33658                 val_constr.data = NULL;
33659         for (size_t i = 0; i < val_constr.datalen; i++) {
33660                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
33661                 LDKSignature val_conv_8_ref;
33662                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
33663                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
33664                 val_constr.data[i] = val_conv_8_ref;
33665         }
33666         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
33667 }
33668
33669 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) {
33670         LDKThirtyTwoBytes channel_id_arg_ref;
33671         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33672         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33673         LDKSignature signature_arg_ref;
33674         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33675         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33676         LDKCVec_SignatureZ htlc_signatures_arg_constr;
33677         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
33678         if (htlc_signatures_arg_constr.datalen > 0)
33679                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33680         else
33681                 htlc_signatures_arg_constr.data = NULL;
33682         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
33683                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
33684                 LDKSignature htlc_signatures_arg_conv_8_ref;
33685                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
33686                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
33687                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
33688         }
33689         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
33690         int64_t ret_ref = 0;
33691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33694         ret_ref = (uintptr_t)ret_var.inner;
33695         if (ret_var.is_owned) {
33696                 ret_ref |= 1;
33697         }
33698         return ret_ref;
33699 }
33700
33701 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
33702         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
33703 int64_t ret_ref = 0;
33704 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33705 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33706 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33707 ret_ref = (uintptr_t)ret_var.inner;
33708 if (ret_var.is_owned) {
33709         ret_ref |= 1;
33710 }
33711         return ret_ref;
33712 }
33713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33714         LDKCommitmentSigned arg_conv;
33715         arg_conv.inner = (void*)(arg & (~1));
33716         arg_conv.is_owned = false;
33717         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33718         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
33719         return ret_conv;
33720 }
33721
33722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33723         LDKCommitmentSigned orig_conv;
33724         orig_conv.inner = (void*)(orig & (~1));
33725         orig_conv.is_owned = false;
33726         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33727         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
33728         int64_t ret_ref = 0;
33729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33732         ret_ref = (uintptr_t)ret_var.inner;
33733         if (ret_var.is_owned) {
33734                 ret_ref |= 1;
33735         }
33736         return ret_ref;
33737 }
33738
33739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33740         LDKRevokeAndACK this_obj_conv;
33741         this_obj_conv.inner = (void*)(this_obj & (~1));
33742         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33744         RevokeAndACK_free(this_obj_conv);
33745 }
33746
33747 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33748         LDKRevokeAndACK this_ptr_conv;
33749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33750         this_ptr_conv.is_owned = false;
33751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33752         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33753         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
33754         return ret_arr;
33755 }
33756
33757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33758         LDKRevokeAndACK this_ptr_conv;
33759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33760         this_ptr_conv.is_owned = false;
33761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33762         LDKThirtyTwoBytes val_ref;
33763         CHECK((*env)->GetArrayLength(env, val) == 32);
33764         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33765         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
33766 }
33767
33768 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
33769         LDKRevokeAndACK this_ptr_conv;
33770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33771         this_ptr_conv.is_owned = false;
33772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33773         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33774         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
33775         return ret_arr;
33776 }
33777
33778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33779         LDKRevokeAndACK this_ptr_conv;
33780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33781         this_ptr_conv.is_owned = false;
33782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33783         LDKThirtyTwoBytes val_ref;
33784         CHECK((*env)->GetArrayLength(env, val) == 32);
33785         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33786         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
33787 }
33788
33789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33790         LDKRevokeAndACK this_ptr_conv;
33791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33792         this_ptr_conv.is_owned = false;
33793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33794         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33795         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
33796         return ret_arr;
33797 }
33798
33799 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) {
33800         LDKRevokeAndACK this_ptr_conv;
33801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33802         this_ptr_conv.is_owned = false;
33803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33804         LDKPublicKey val_ref;
33805         CHECK((*env)->GetArrayLength(env, val) == 33);
33806         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33807         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
33808 }
33809
33810 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) {
33811         LDKThirtyTwoBytes channel_id_arg_ref;
33812         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33813         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33814         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
33815         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
33816         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
33817         LDKPublicKey next_per_commitment_point_arg_ref;
33818         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
33819         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
33820         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
33821         int64_t ret_ref = 0;
33822         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33823         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33825         ret_ref = (uintptr_t)ret_var.inner;
33826         if (ret_var.is_owned) {
33827                 ret_ref |= 1;
33828         }
33829         return ret_ref;
33830 }
33831
33832 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
33833         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
33834 int64_t ret_ref = 0;
33835 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33836 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33837 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33838 ret_ref = (uintptr_t)ret_var.inner;
33839 if (ret_var.is_owned) {
33840         ret_ref |= 1;
33841 }
33842         return ret_ref;
33843 }
33844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33845         LDKRevokeAndACK arg_conv;
33846         arg_conv.inner = (void*)(arg & (~1));
33847         arg_conv.is_owned = false;
33848         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33849         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
33850         return ret_conv;
33851 }
33852
33853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33854         LDKRevokeAndACK orig_conv;
33855         orig_conv.inner = (void*)(orig & (~1));
33856         orig_conv.is_owned = false;
33857         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33858         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
33859         int64_t ret_ref = 0;
33860         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33861         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33863         ret_ref = (uintptr_t)ret_var.inner;
33864         if (ret_var.is_owned) {
33865                 ret_ref |= 1;
33866         }
33867         return ret_ref;
33868 }
33869
33870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33871         LDKUpdateFee this_obj_conv;
33872         this_obj_conv.inner = (void*)(this_obj & (~1));
33873         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33875         UpdateFee_free(this_obj_conv);
33876 }
33877
33878 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33879         LDKUpdateFee 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33884         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
33885         return ret_arr;
33886 }
33887
33888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33889         LDKUpdateFee this_ptr_conv;
33890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33891         this_ptr_conv.is_owned = false;
33892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33893         LDKThirtyTwoBytes val_ref;
33894         CHECK((*env)->GetArrayLength(env, val) == 32);
33895         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33896         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
33897 }
33898
33899 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
33900         LDKUpdateFee this_ptr_conv;
33901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33902         this_ptr_conv.is_owned = false;
33903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33904         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
33905         return ret_conv;
33906 }
33907
33908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33909         LDKUpdateFee this_ptr_conv;
33910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33911         this_ptr_conv.is_owned = false;
33912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33913         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
33914 }
33915
33916 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) {
33917         LDKThirtyTwoBytes channel_id_arg_ref;
33918         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33919         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33920         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
33921         int64_t ret_ref = 0;
33922         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33923         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33925         ret_ref = (uintptr_t)ret_var.inner;
33926         if (ret_var.is_owned) {
33927                 ret_ref |= 1;
33928         }
33929         return ret_ref;
33930 }
33931
33932 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
33933         LDKUpdateFee ret_var = UpdateFee_clone(arg);
33934 int64_t ret_ref = 0;
33935 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33936 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33937 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33938 ret_ref = (uintptr_t)ret_var.inner;
33939 if (ret_var.is_owned) {
33940         ret_ref |= 1;
33941 }
33942         return ret_ref;
33943 }
33944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33945         LDKUpdateFee arg_conv;
33946         arg_conv.inner = (void*)(arg & (~1));
33947         arg_conv.is_owned = false;
33948         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33949         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
33950         return ret_conv;
33951 }
33952
33953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33954         LDKUpdateFee orig_conv;
33955         orig_conv.inner = (void*)(orig & (~1));
33956         orig_conv.is_owned = false;
33957         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33958         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
33959         int64_t ret_ref = 0;
33960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33963         ret_ref = (uintptr_t)ret_var.inner;
33964         if (ret_var.is_owned) {
33965                 ret_ref |= 1;
33966         }
33967         return ret_ref;
33968 }
33969
33970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33971         LDKDataLossProtect this_obj_conv;
33972         this_obj_conv.inner = (void*)(this_obj & (~1));
33973         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33975         DataLossProtect_free(this_obj_conv);
33976 }
33977
33978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
33979         LDKDataLossProtect this_ptr_conv;
33980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33981         this_ptr_conv.is_owned = false;
33982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33983         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33984         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
33985         return ret_arr;
33986 }
33987
33988 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) {
33989         LDKDataLossProtect this_ptr_conv;
33990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33991         this_ptr_conv.is_owned = false;
33992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33993         LDKThirtyTwoBytes val_ref;
33994         CHECK((*env)->GetArrayLength(env, val) == 32);
33995         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33996         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
33997 }
33998
33999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34000         LDKDataLossProtect this_ptr_conv;
34001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34002         this_ptr_conv.is_owned = false;
34003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34004         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34005         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
34006         return ret_arr;
34007 }
34008
34009 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) {
34010         LDKDataLossProtect this_ptr_conv;
34011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34012         this_ptr_conv.is_owned = false;
34013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34014         LDKPublicKey val_ref;
34015         CHECK((*env)->GetArrayLength(env, val) == 33);
34016         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34017         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
34018 }
34019
34020 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) {
34021         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
34022         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
34023         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
34024         LDKPublicKey my_current_per_commitment_point_arg_ref;
34025         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
34026         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
34027         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
34028         int64_t ret_ref = 0;
34029         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34030         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34032         ret_ref = (uintptr_t)ret_var.inner;
34033         if (ret_var.is_owned) {
34034                 ret_ref |= 1;
34035         }
34036         return ret_ref;
34037 }
34038
34039 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
34040         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
34041 int64_t ret_ref = 0;
34042 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34043 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34044 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34045 ret_ref = (uintptr_t)ret_var.inner;
34046 if (ret_var.is_owned) {
34047         ret_ref |= 1;
34048 }
34049         return ret_ref;
34050 }
34051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34052         LDKDataLossProtect arg_conv;
34053         arg_conv.inner = (void*)(arg & (~1));
34054         arg_conv.is_owned = false;
34055         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34056         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
34057         return ret_conv;
34058 }
34059
34060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34061         LDKDataLossProtect orig_conv;
34062         orig_conv.inner = (void*)(orig & (~1));
34063         orig_conv.is_owned = false;
34064         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34065         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
34066         int64_t ret_ref = 0;
34067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34070         ret_ref = (uintptr_t)ret_var.inner;
34071         if (ret_var.is_owned) {
34072                 ret_ref |= 1;
34073         }
34074         return ret_ref;
34075 }
34076
34077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34078         LDKChannelReestablish this_obj_conv;
34079         this_obj_conv.inner = (void*)(this_obj & (~1));
34080         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34082         ChannelReestablish_free(this_obj_conv);
34083 }
34084
34085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34086         LDKChannelReestablish this_ptr_conv;
34087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34088         this_ptr_conv.is_owned = false;
34089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34090         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34091         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
34092         return ret_arr;
34093 }
34094
34095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34096         LDKChannelReestablish this_ptr_conv;
34097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34098         this_ptr_conv.is_owned = false;
34099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34100         LDKThirtyTwoBytes val_ref;
34101         CHECK((*env)->GetArrayLength(env, val) == 32);
34102         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34103         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
34104 }
34105
34106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34107         LDKChannelReestablish this_ptr_conv;
34108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34109         this_ptr_conv.is_owned = false;
34110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34111         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
34112         return ret_conv;
34113 }
34114
34115 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) {
34116         LDKChannelReestablish this_ptr_conv;
34117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34118         this_ptr_conv.is_owned = false;
34119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34120         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
34121 }
34122
34123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
34124         LDKChannelReestablish this_ptr_conv;
34125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34126         this_ptr_conv.is_owned = false;
34127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34128         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
34129         return ret_conv;
34130 }
34131
34132 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) {
34133         LDKChannelReestablish 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         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
34138 }
34139
34140 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
34141         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
34142 int64_t ret_ref = 0;
34143 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34144 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34145 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34146 ret_ref = (uintptr_t)ret_var.inner;
34147 if (ret_var.is_owned) {
34148         ret_ref |= 1;
34149 }
34150         return ret_ref;
34151 }
34152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34153         LDKChannelReestablish arg_conv;
34154         arg_conv.inner = (void*)(arg & (~1));
34155         arg_conv.is_owned = false;
34156         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34157         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
34158         return ret_conv;
34159 }
34160
34161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34162         LDKChannelReestablish orig_conv;
34163         orig_conv.inner = (void*)(orig & (~1));
34164         orig_conv.is_owned = false;
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34166         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
34167         int64_t ret_ref = 0;
34168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34171         ret_ref = (uintptr_t)ret_var.inner;
34172         if (ret_var.is_owned) {
34173                 ret_ref |= 1;
34174         }
34175         return ret_ref;
34176 }
34177
34178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34179         LDKAnnouncementSignatures this_obj_conv;
34180         this_obj_conv.inner = (void*)(this_obj & (~1));
34181         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34183         AnnouncementSignatures_free(this_obj_conv);
34184 }
34185
34186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34187         LDKAnnouncementSignatures this_ptr_conv;
34188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34189         this_ptr_conv.is_owned = false;
34190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34191         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34192         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
34193         return ret_arr;
34194 }
34195
34196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34197         LDKAnnouncementSignatures this_ptr_conv;
34198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34199         this_ptr_conv.is_owned = false;
34200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34201         LDKThirtyTwoBytes val_ref;
34202         CHECK((*env)->GetArrayLength(env, val) == 32);
34203         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34204         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
34205 }
34206
34207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34208         LDKAnnouncementSignatures this_ptr_conv;
34209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34210         this_ptr_conv.is_owned = false;
34211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34212         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
34213         return ret_conv;
34214 }
34215
34216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34217         LDKAnnouncementSignatures 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         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
34222 }
34223
34224 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34225         LDKAnnouncementSignatures this_ptr_conv;
34226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34227         this_ptr_conv.is_owned = false;
34228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34229         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34230         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
34231         return ret_arr;
34232 }
34233
34234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34235         LDKAnnouncementSignatures this_ptr_conv;
34236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34237         this_ptr_conv.is_owned = false;
34238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34239         LDKSignature val_ref;
34240         CHECK((*env)->GetArrayLength(env, val) == 64);
34241         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34242         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
34243 }
34244
34245 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34246         LDKAnnouncementSignatures this_ptr_conv;
34247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34248         this_ptr_conv.is_owned = false;
34249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34250         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34251         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
34252         return ret_arr;
34253 }
34254
34255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34256         LDKAnnouncementSignatures this_ptr_conv;
34257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34258         this_ptr_conv.is_owned = false;
34259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34260         LDKSignature val_ref;
34261         CHECK((*env)->GetArrayLength(env, val) == 64);
34262         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34263         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
34264 }
34265
34266 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) {
34267         LDKThirtyTwoBytes channel_id_arg_ref;
34268         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34269         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34270         LDKSignature node_signature_arg_ref;
34271         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
34272         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
34273         LDKSignature bitcoin_signature_arg_ref;
34274         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
34275         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
34276         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
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 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
34289         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
34290 int64_t ret_ref = 0;
34291 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34292 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34293 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34294 ret_ref = (uintptr_t)ret_var.inner;
34295 if (ret_var.is_owned) {
34296         ret_ref |= 1;
34297 }
34298         return ret_ref;
34299 }
34300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34301         LDKAnnouncementSignatures arg_conv;
34302         arg_conv.inner = (void*)(arg & (~1));
34303         arg_conv.is_owned = false;
34304         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34305         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
34306         return ret_conv;
34307 }
34308
34309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34310         LDKAnnouncementSignatures orig_conv;
34311         orig_conv.inner = (void*)(orig & (~1));
34312         orig_conv.is_owned = false;
34313         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34314         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
34315         int64_t ret_ref = 0;
34316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34319         ret_ref = (uintptr_t)ret_var.inner;
34320         if (ret_var.is_owned) {
34321                 ret_ref |= 1;
34322         }
34323         return ret_ref;
34324 }
34325
34326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34327         if ((this_ptr & 1) != 0) return;
34328         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34329         CHECK_ACCESS(this_ptr_ptr);
34330         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
34331         FREE((void*)this_ptr);
34332         NetAddress_free(this_ptr_conv);
34333 }
34334
34335 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
34336         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34337         *ret_copy = NetAddress_clone(arg);
34338 int64_t ret_ref = (uintptr_t)ret_copy;
34339         return ret_ref;
34340 }
34341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34342         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
34343         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
34344         return ret_conv;
34345 }
34346
34347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34348         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
34349         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34350         *ret_copy = NetAddress_clone(orig_conv);
34351         int64_t ret_ref = (uintptr_t)ret_copy;
34352         return ret_ref;
34353 }
34354
34355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
34356         LDKFourBytes addr_ref;
34357         CHECK((*env)->GetArrayLength(env, addr) == 4);
34358         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
34359         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34360         *ret_copy = NetAddress_ipv4(addr_ref, port);
34361         int64_t ret_ref = (uintptr_t)ret_copy;
34362         return ret_ref;
34363 }
34364
34365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
34366         LDKSixteenBytes addr_ref;
34367         CHECK((*env)->GetArrayLength(env, addr) == 16);
34368         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
34369         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34370         *ret_copy = NetAddress_ipv6(addr_ref, port);
34371         int64_t ret_ref = (uintptr_t)ret_copy;
34372         return ret_ref;
34373 }
34374
34375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
34376         LDKTwelveBytes a_ref;
34377         CHECK((*env)->GetArrayLength(env, a) == 12);
34378         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
34379         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34380         *ret_copy = NetAddress_onion_v2(a_ref);
34381         int64_t ret_ref = (uintptr_t)ret_copy;
34382         return ret_ref;
34383 }
34384
34385 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) {
34386         LDKThirtyTwoBytes ed25519_pubkey_ref;
34387         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
34388         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
34389         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
34390         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
34391         int64_t ret_ref = (uintptr_t)ret_copy;
34392         return ret_ref;
34393 }
34394
34395 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
34396         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
34397         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
34398         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34399         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34400         CVec_u8Z_free(ret_var);
34401         return ret_arr;
34402 }
34403
34404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34405         LDKu8slice ser_ref;
34406         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34407         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34408         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
34409         *ret_conv = NetAddress_read(ser_ref);
34410         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34411         return (int64_t)ret_conv;
34412 }
34413
34414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34415         LDKUnsignedNodeAnnouncement this_obj_conv;
34416         this_obj_conv.inner = (void*)(this_obj & (~1));
34417         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34419         UnsignedNodeAnnouncement_free(this_obj_conv);
34420 }
34421
34422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
34423         LDKUnsignedNodeAnnouncement this_ptr_conv;
34424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34425         this_ptr_conv.is_owned = false;
34426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34427         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
34428         int64_t ret_ref = 0;
34429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34432         ret_ref = (uintptr_t)ret_var.inner;
34433         if (ret_var.is_owned) {
34434                 ret_ref |= 1;
34435         }
34436         return ret_ref;
34437 }
34438
34439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34440         LDKUnsignedNodeAnnouncement this_ptr_conv;
34441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34442         this_ptr_conv.is_owned = false;
34443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34444         LDKNodeFeatures val_conv;
34445         val_conv.inner = (void*)(val & (~1));
34446         val_conv.is_owned = (val & 1) || (val == 0);
34447         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34448         val_conv = NodeFeatures_clone(&val_conv);
34449         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
34450 }
34451
34452 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
34453         LDKUnsignedNodeAnnouncement this_ptr_conv;
34454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34455         this_ptr_conv.is_owned = false;
34456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34457         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
34458         return ret_conv;
34459 }
34460
34461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34462         LDKUnsignedNodeAnnouncement this_ptr_conv;
34463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34464         this_ptr_conv.is_owned = false;
34465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34466         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
34467 }
34468
34469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34470         LDKUnsignedNodeAnnouncement this_ptr_conv;
34471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34472         this_ptr_conv.is_owned = false;
34473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34474         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34475         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
34476         return ret_arr;
34477 }
34478
34479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34480         LDKUnsignedNodeAnnouncement 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         LDKPublicKey val_ref;
34485         CHECK((*env)->GetArrayLength(env, val) == 33);
34486         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34487         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
34488 }
34489
34490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
34491         LDKUnsignedNodeAnnouncement this_ptr_conv;
34492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34493         this_ptr_conv.is_owned = false;
34494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34495         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
34496         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
34497         return ret_arr;
34498 }
34499
34500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34501         LDKUnsignedNodeAnnouncement this_ptr_conv;
34502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34503         this_ptr_conv.is_owned = false;
34504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34505         LDKThreeBytes val_ref;
34506         CHECK((*env)->GetArrayLength(env, val) == 3);
34507         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
34508         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
34509 }
34510
34511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
34512         LDKUnsignedNodeAnnouncement this_ptr_conv;
34513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34514         this_ptr_conv.is_owned = false;
34515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34516         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34517         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
34518         return ret_arr;
34519 }
34520
34521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34522         LDKUnsignedNodeAnnouncement this_ptr_conv;
34523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34524         this_ptr_conv.is_owned = false;
34525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34526         LDKThirtyTwoBytes val_ref;
34527         CHECK((*env)->GetArrayLength(env, val) == 32);
34528         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34529         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
34530 }
34531
34532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34533         LDKUnsignedNodeAnnouncement this_ptr_conv;
34534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34535         this_ptr_conv.is_owned = false;
34536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34537         LDKCVec_NetAddressZ val_constr;
34538         val_constr.datalen = (*env)->GetArrayLength(env, val);
34539         if (val_constr.datalen > 0)
34540                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
34541         else
34542                 val_constr.data = NULL;
34543         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34544         for (size_t m = 0; m < val_constr.datalen; m++) {
34545                 int64_t val_conv_12 = val_vals[m];
34546                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
34547                 CHECK_ACCESS(val_conv_12_ptr);
34548                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
34549                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
34550                 val_constr.data[m] = val_conv_12_conv;
34551         }
34552         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34553         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
34554 }
34555
34556 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
34557         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
34558 int64_t ret_ref = 0;
34559 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34560 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34561 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34562 ret_ref = (uintptr_t)ret_var.inner;
34563 if (ret_var.is_owned) {
34564         ret_ref |= 1;
34565 }
34566         return ret_ref;
34567 }
34568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34569         LDKUnsignedNodeAnnouncement arg_conv;
34570         arg_conv.inner = (void*)(arg & (~1));
34571         arg_conv.is_owned = false;
34572         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34573         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
34574         return ret_conv;
34575 }
34576
34577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34578         LDKUnsignedNodeAnnouncement orig_conv;
34579         orig_conv.inner = (void*)(orig & (~1));
34580         orig_conv.is_owned = false;
34581         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34582         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
34583         int64_t ret_ref = 0;
34584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34587         ret_ref = (uintptr_t)ret_var.inner;
34588         if (ret_var.is_owned) {
34589                 ret_ref |= 1;
34590         }
34591         return ret_ref;
34592 }
34593
34594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34595         LDKNodeAnnouncement this_obj_conv;
34596         this_obj_conv.inner = (void*)(this_obj & (~1));
34597         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34599         NodeAnnouncement_free(this_obj_conv);
34600 }
34601
34602 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34603         LDKNodeAnnouncement this_ptr_conv;
34604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34605         this_ptr_conv.is_owned = false;
34606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34607         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34608         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
34609         return ret_arr;
34610 }
34611
34612 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34613         LDKNodeAnnouncement this_ptr_conv;
34614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34615         this_ptr_conv.is_owned = false;
34616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34617         LDKSignature val_ref;
34618         CHECK((*env)->GetArrayLength(env, val) == 64);
34619         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34620         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
34621 }
34622
34623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
34624         LDKNodeAnnouncement this_ptr_conv;
34625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34626         this_ptr_conv.is_owned = false;
34627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34628         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
34629         int64_t ret_ref = 0;
34630         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34631         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34633         ret_ref = (uintptr_t)ret_var.inner;
34634         if (ret_var.is_owned) {
34635                 ret_ref |= 1;
34636         }
34637         return ret_ref;
34638 }
34639
34640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34641         LDKNodeAnnouncement this_ptr_conv;
34642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34643         this_ptr_conv.is_owned = false;
34644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34645         LDKUnsignedNodeAnnouncement val_conv;
34646         val_conv.inner = (void*)(val & (~1));
34647         val_conv.is_owned = (val & 1) || (val == 0);
34648         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34649         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
34650         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
34651 }
34652
34653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
34654         LDKSignature signature_arg_ref;
34655         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34656         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34657         LDKUnsignedNodeAnnouncement contents_arg_conv;
34658         contents_arg_conv.inner = (void*)(contents_arg & (~1));
34659         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
34660         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
34661         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
34662         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
34663         int64_t ret_ref = 0;
34664         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34665         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34667         ret_ref = (uintptr_t)ret_var.inner;
34668         if (ret_var.is_owned) {
34669                 ret_ref |= 1;
34670         }
34671         return ret_ref;
34672 }
34673
34674 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
34675         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
34676 int64_t ret_ref = 0;
34677 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34678 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34679 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34680 ret_ref = (uintptr_t)ret_var.inner;
34681 if (ret_var.is_owned) {
34682         ret_ref |= 1;
34683 }
34684         return ret_ref;
34685 }
34686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34687         LDKNodeAnnouncement arg_conv;
34688         arg_conv.inner = (void*)(arg & (~1));
34689         arg_conv.is_owned = false;
34690         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34691         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
34692         return ret_conv;
34693 }
34694
34695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34696         LDKNodeAnnouncement orig_conv;
34697         orig_conv.inner = (void*)(orig & (~1));
34698         orig_conv.is_owned = false;
34699         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34700         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
34701         int64_t ret_ref = 0;
34702         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34703         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34705         ret_ref = (uintptr_t)ret_var.inner;
34706         if (ret_var.is_owned) {
34707                 ret_ref |= 1;
34708         }
34709         return ret_ref;
34710 }
34711
34712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34713         LDKUnsignedChannelAnnouncement this_obj_conv;
34714         this_obj_conv.inner = (void*)(this_obj & (~1));
34715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34717         UnsignedChannelAnnouncement_free(this_obj_conv);
34718 }
34719
34720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
34721         LDKUnsignedChannelAnnouncement this_ptr_conv;
34722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34723         this_ptr_conv.is_owned = false;
34724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34725         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
34726         int64_t ret_ref = 0;
34727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34730         ret_ref = (uintptr_t)ret_var.inner;
34731         if (ret_var.is_owned) {
34732                 ret_ref |= 1;
34733         }
34734         return ret_ref;
34735 }
34736
34737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34738         LDKUnsignedChannelAnnouncement this_ptr_conv;
34739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34740         this_ptr_conv.is_owned = false;
34741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34742         LDKChannelFeatures val_conv;
34743         val_conv.inner = (void*)(val & (~1));
34744         val_conv.is_owned = (val & 1) || (val == 0);
34745         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34746         val_conv = ChannelFeatures_clone(&val_conv);
34747         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
34748 }
34749
34750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34751         LDKUnsignedChannelAnnouncement this_ptr_conv;
34752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34753         this_ptr_conv.is_owned = false;
34754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34755         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34756         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
34757         return ret_arr;
34758 }
34759
34760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34761         LDKUnsignedChannelAnnouncement this_ptr_conv;
34762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34763         this_ptr_conv.is_owned = false;
34764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34765         LDKThirtyTwoBytes val_ref;
34766         CHECK((*env)->GetArrayLength(env, val) == 32);
34767         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34768         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
34769 }
34770
34771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34772         LDKUnsignedChannelAnnouncement this_ptr_conv;
34773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34774         this_ptr_conv.is_owned = false;
34775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34776         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
34777         return ret_conv;
34778 }
34779
34780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34781         LDKUnsignedChannelAnnouncement this_ptr_conv;
34782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34783         this_ptr_conv.is_owned = false;
34784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34785         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
34786 }
34787
34788 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34789         LDKUnsignedChannelAnnouncement this_ptr_conv;
34790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34791         this_ptr_conv.is_owned = false;
34792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34793         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34794         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
34795         return ret_arr;
34796 }
34797
34798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34799         LDKUnsignedChannelAnnouncement this_ptr_conv;
34800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34801         this_ptr_conv.is_owned = false;
34802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34803         LDKPublicKey val_ref;
34804         CHECK((*env)->GetArrayLength(env, val) == 33);
34805         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34806         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
34807 }
34808
34809 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34810         LDKUnsignedChannelAnnouncement this_ptr_conv;
34811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34812         this_ptr_conv.is_owned = false;
34813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34814         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34815         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
34816         return ret_arr;
34817 }
34818
34819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34820         LDKUnsignedChannelAnnouncement this_ptr_conv;
34821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34822         this_ptr_conv.is_owned = false;
34823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34824         LDKPublicKey val_ref;
34825         CHECK((*env)->GetArrayLength(env, val) == 33);
34826         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34827         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
34828 }
34829
34830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34831         LDKUnsignedChannelAnnouncement this_ptr_conv;
34832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34833         this_ptr_conv.is_owned = false;
34834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34835         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34836         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
34837         return ret_arr;
34838 }
34839
34840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34841         LDKUnsignedChannelAnnouncement this_ptr_conv;
34842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34843         this_ptr_conv.is_owned = false;
34844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34845         LDKPublicKey val_ref;
34846         CHECK((*env)->GetArrayLength(env, val) == 33);
34847         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34848         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
34849 }
34850
34851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34852         LDKUnsignedChannelAnnouncement this_ptr_conv;
34853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34854         this_ptr_conv.is_owned = false;
34855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34856         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34857         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
34858         return ret_arr;
34859 }
34860
34861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34862         LDKUnsignedChannelAnnouncement this_ptr_conv;
34863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34864         this_ptr_conv.is_owned = false;
34865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34866         LDKPublicKey val_ref;
34867         CHECK((*env)->GetArrayLength(env, val) == 33);
34868         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34869         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
34870 }
34871
34872 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
34873         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
34874 int64_t ret_ref = 0;
34875 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34876 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34877 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34878 ret_ref = (uintptr_t)ret_var.inner;
34879 if (ret_var.is_owned) {
34880         ret_ref |= 1;
34881 }
34882         return ret_ref;
34883 }
34884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34885         LDKUnsignedChannelAnnouncement arg_conv;
34886         arg_conv.inner = (void*)(arg & (~1));
34887         arg_conv.is_owned = false;
34888         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34889         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
34890         return ret_conv;
34891 }
34892
34893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34894         LDKUnsignedChannelAnnouncement orig_conv;
34895         orig_conv.inner = (void*)(orig & (~1));
34896         orig_conv.is_owned = false;
34897         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34898         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
34899         int64_t ret_ref = 0;
34900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34903         ret_ref = (uintptr_t)ret_var.inner;
34904         if (ret_var.is_owned) {
34905                 ret_ref |= 1;
34906         }
34907         return ret_ref;
34908 }
34909
34910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34911         LDKChannelAnnouncement this_obj_conv;
34912         this_obj_conv.inner = (void*)(this_obj & (~1));
34913         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34915         ChannelAnnouncement_free(this_obj_conv);
34916 }
34917
34918 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34919         LDKChannelAnnouncement this_ptr_conv;
34920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34921         this_ptr_conv.is_owned = false;
34922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34923         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34924         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
34925         return ret_arr;
34926 }
34927
34928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34929         LDKChannelAnnouncement this_ptr_conv;
34930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34931         this_ptr_conv.is_owned = false;
34932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34933         LDKSignature val_ref;
34934         CHECK((*env)->GetArrayLength(env, val) == 64);
34935         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34936         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
34937 }
34938
34939 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34940         LDKChannelAnnouncement this_ptr_conv;
34941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34942         this_ptr_conv.is_owned = false;
34943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34944         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34945         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
34946         return ret_arr;
34947 }
34948
34949 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34950         LDKChannelAnnouncement this_ptr_conv;
34951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34952         this_ptr_conv.is_owned = false;
34953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34954         LDKSignature val_ref;
34955         CHECK((*env)->GetArrayLength(env, val) == 64);
34956         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34957         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
34958 }
34959
34960 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
34961         LDKChannelAnnouncement this_ptr_conv;
34962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34963         this_ptr_conv.is_owned = false;
34964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34965         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34966         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
34967         return ret_arr;
34968 }
34969
34970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34971         LDKChannelAnnouncement this_ptr_conv;
34972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34973         this_ptr_conv.is_owned = false;
34974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34975         LDKSignature val_ref;
34976         CHECK((*env)->GetArrayLength(env, val) == 64);
34977         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34978         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
34979 }
34980
34981 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
34982         LDKChannelAnnouncement this_ptr_conv;
34983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34984         this_ptr_conv.is_owned = false;
34985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34986         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34987         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
34988         return ret_arr;
34989 }
34990
34991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34992         LDKChannelAnnouncement this_ptr_conv;
34993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34994         this_ptr_conv.is_owned = false;
34995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34996         LDKSignature val_ref;
34997         CHECK((*env)->GetArrayLength(env, val) == 64);
34998         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34999         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
35000 }
35001
35002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35003         LDKChannelAnnouncement this_ptr_conv;
35004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35005         this_ptr_conv.is_owned = false;
35006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35007         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
35008         int64_t ret_ref = 0;
35009         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35010         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35012         ret_ref = (uintptr_t)ret_var.inner;
35013         if (ret_var.is_owned) {
35014                 ret_ref |= 1;
35015         }
35016         return ret_ref;
35017 }
35018
35019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35020         LDKChannelAnnouncement this_ptr_conv;
35021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35022         this_ptr_conv.is_owned = false;
35023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35024         LDKUnsignedChannelAnnouncement val_conv;
35025         val_conv.inner = (void*)(val & (~1));
35026         val_conv.is_owned = (val & 1) || (val == 0);
35027         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35028         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
35029         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
35030 }
35031
35032 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) {
35033         LDKSignature node_signature_1_arg_ref;
35034         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
35035         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
35036         LDKSignature node_signature_2_arg_ref;
35037         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
35038         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
35039         LDKSignature bitcoin_signature_1_arg_ref;
35040         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
35041         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
35042         LDKSignature bitcoin_signature_2_arg_ref;
35043         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
35044         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
35045         LDKUnsignedChannelAnnouncement contents_arg_conv;
35046         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35047         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35048         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35049         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
35050         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);
35051         int64_t ret_ref = 0;
35052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35055         ret_ref = (uintptr_t)ret_var.inner;
35056         if (ret_var.is_owned) {
35057                 ret_ref |= 1;
35058         }
35059         return ret_ref;
35060 }
35061
35062 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
35063         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
35064 int64_t ret_ref = 0;
35065 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35066 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35067 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35068 ret_ref = (uintptr_t)ret_var.inner;
35069 if (ret_var.is_owned) {
35070         ret_ref |= 1;
35071 }
35072         return ret_ref;
35073 }
35074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35075         LDKChannelAnnouncement arg_conv;
35076         arg_conv.inner = (void*)(arg & (~1));
35077         arg_conv.is_owned = false;
35078         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35079         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
35080         return ret_conv;
35081 }
35082
35083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35084         LDKChannelAnnouncement orig_conv;
35085         orig_conv.inner = (void*)(orig & (~1));
35086         orig_conv.is_owned = false;
35087         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35088         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
35089         int64_t ret_ref = 0;
35090         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35091         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35093         ret_ref = (uintptr_t)ret_var.inner;
35094         if (ret_var.is_owned) {
35095                 ret_ref |= 1;
35096         }
35097         return ret_ref;
35098 }
35099
35100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35101         LDKUnsignedChannelUpdate this_obj_conv;
35102         this_obj_conv.inner = (void*)(this_obj & (~1));
35103         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35105         UnsignedChannelUpdate_free(this_obj_conv);
35106 }
35107
35108 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35109         LDKUnsignedChannelUpdate this_ptr_conv;
35110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35111         this_ptr_conv.is_owned = false;
35112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35113         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35114         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
35115         return ret_arr;
35116 }
35117
35118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35119         LDKUnsignedChannelUpdate this_ptr_conv;
35120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35121         this_ptr_conv.is_owned = false;
35122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35123         LDKThirtyTwoBytes val_ref;
35124         CHECK((*env)->GetArrayLength(env, val) == 32);
35125         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35126         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
35127 }
35128
35129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35130         LDKUnsignedChannelUpdate this_ptr_conv;
35131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35132         this_ptr_conv.is_owned = false;
35133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35134         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
35135         return ret_conv;
35136 }
35137
35138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35139         LDKUnsignedChannelUpdate this_ptr_conv;
35140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35141         this_ptr_conv.is_owned = false;
35142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35143         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
35144 }
35145
35146 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35147         LDKUnsignedChannelUpdate this_ptr_conv;
35148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35149         this_ptr_conv.is_owned = false;
35150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35151         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
35152         return ret_conv;
35153 }
35154
35155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35156         LDKUnsignedChannelUpdate this_ptr_conv;
35157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35158         this_ptr_conv.is_owned = false;
35159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35160         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
35161 }
35162
35163 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
35164         LDKUnsignedChannelUpdate 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         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
35169         return ret_conv;
35170 }
35171
35172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
35173         LDKUnsignedChannelUpdate this_ptr_conv;
35174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35175         this_ptr_conv.is_owned = false;
35176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35177         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
35178 }
35179
35180 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
35181         LDKUnsignedChannelUpdate this_ptr_conv;
35182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35183         this_ptr_conv.is_owned = false;
35184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35185         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
35186         return ret_conv;
35187 }
35188
35189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35190         LDKUnsignedChannelUpdate this_ptr_conv;
35191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35192         this_ptr_conv.is_owned = false;
35193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35194         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
35195 }
35196
35197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35198         LDKUnsignedChannelUpdate this_ptr_conv;
35199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35200         this_ptr_conv.is_owned = false;
35201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35202         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
35203         return ret_conv;
35204 }
35205
35206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35207         LDKUnsignedChannelUpdate this_ptr_conv;
35208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35209         this_ptr_conv.is_owned = false;
35210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35211         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
35212 }
35213
35214 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35215         LDKUnsignedChannelUpdate this_ptr_conv;
35216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35217         this_ptr_conv.is_owned = false;
35218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35219         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
35220         return ret_conv;
35221 }
35222
35223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35224         LDKUnsignedChannelUpdate 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         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
35229 }
35230
35231 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
35232         LDKUnsignedChannelUpdate this_ptr_conv;
35233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35234         this_ptr_conv.is_owned = false;
35235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35236         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
35237         return ret_conv;
35238 }
35239
35240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35241         LDKUnsignedChannelUpdate this_ptr_conv;
35242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35243         this_ptr_conv.is_owned = false;
35244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35245         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
35246 }
35247
35248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35249         LDKUnsignedChannelUpdate this_ptr_conv;
35250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35251         this_ptr_conv.is_owned = false;
35252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35253         LDKCVec_u8Z val_ref;
35254         val_ref.datalen = (*env)->GetArrayLength(env, val);
35255         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35256         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
35257         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
35258 }
35259
35260 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
35261         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
35262 int64_t ret_ref = 0;
35263 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35264 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35265 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35266 ret_ref = (uintptr_t)ret_var.inner;
35267 if (ret_var.is_owned) {
35268         ret_ref |= 1;
35269 }
35270         return ret_ref;
35271 }
35272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35273         LDKUnsignedChannelUpdate arg_conv;
35274         arg_conv.inner = (void*)(arg & (~1));
35275         arg_conv.is_owned = false;
35276         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35277         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
35278         return ret_conv;
35279 }
35280
35281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35282         LDKUnsignedChannelUpdate orig_conv;
35283         orig_conv.inner = (void*)(orig & (~1));
35284         orig_conv.is_owned = false;
35285         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35286         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
35287         int64_t ret_ref = 0;
35288         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35289         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35291         ret_ref = (uintptr_t)ret_var.inner;
35292         if (ret_var.is_owned) {
35293                 ret_ref |= 1;
35294         }
35295         return ret_ref;
35296 }
35297
35298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35299         LDKChannelUpdate this_obj_conv;
35300         this_obj_conv.inner = (void*)(this_obj & (~1));
35301         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35303         ChannelUpdate_free(this_obj_conv);
35304 }
35305
35306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35307         LDKChannelUpdate this_ptr_conv;
35308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35309         this_ptr_conv.is_owned = false;
35310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35311         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35312         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
35313         return ret_arr;
35314 }
35315
35316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35317         LDKChannelUpdate this_ptr_conv;
35318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35319         this_ptr_conv.is_owned = false;
35320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35321         LDKSignature val_ref;
35322         CHECK((*env)->GetArrayLength(env, val) == 64);
35323         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35324         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
35325 }
35326
35327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35328         LDKChannelUpdate this_ptr_conv;
35329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35330         this_ptr_conv.is_owned = false;
35331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35332         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
35333         int64_t ret_ref = 0;
35334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35337         ret_ref = (uintptr_t)ret_var.inner;
35338         if (ret_var.is_owned) {
35339                 ret_ref |= 1;
35340         }
35341         return ret_ref;
35342 }
35343
35344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35345         LDKChannelUpdate this_ptr_conv;
35346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35347         this_ptr_conv.is_owned = false;
35348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35349         LDKUnsignedChannelUpdate val_conv;
35350         val_conv.inner = (void*)(val & (~1));
35351         val_conv.is_owned = (val & 1) || (val == 0);
35352         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35353         val_conv = UnsignedChannelUpdate_clone(&val_conv);
35354         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
35355 }
35356
35357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
35358         LDKSignature signature_arg_ref;
35359         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35360         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35361         LDKUnsignedChannelUpdate contents_arg_conv;
35362         contents_arg_conv.inner = (void*)(contents_arg & (~1));
35363         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
35364         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35365         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
35366         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
35367         int64_t ret_ref = 0;
35368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35371         ret_ref = (uintptr_t)ret_var.inner;
35372         if (ret_var.is_owned) {
35373                 ret_ref |= 1;
35374         }
35375         return ret_ref;
35376 }
35377
35378 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
35379         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
35380 int64_t ret_ref = 0;
35381 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35382 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35383 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35384 ret_ref = (uintptr_t)ret_var.inner;
35385 if (ret_var.is_owned) {
35386         ret_ref |= 1;
35387 }
35388         return ret_ref;
35389 }
35390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35391         LDKChannelUpdate arg_conv;
35392         arg_conv.inner = (void*)(arg & (~1));
35393         arg_conv.is_owned = false;
35394         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35395         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
35396         return ret_conv;
35397 }
35398
35399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35400         LDKChannelUpdate orig_conv;
35401         orig_conv.inner = (void*)(orig & (~1));
35402         orig_conv.is_owned = false;
35403         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35404         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
35405         int64_t ret_ref = 0;
35406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35409         ret_ref = (uintptr_t)ret_var.inner;
35410         if (ret_var.is_owned) {
35411                 ret_ref |= 1;
35412         }
35413         return ret_ref;
35414 }
35415
35416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35417         LDKQueryChannelRange this_obj_conv;
35418         this_obj_conv.inner = (void*)(this_obj & (~1));
35419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35421         QueryChannelRange_free(this_obj_conv);
35422 }
35423
35424 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35425         LDKQueryChannelRange this_ptr_conv;
35426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35427         this_ptr_conv.is_owned = false;
35428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35429         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35430         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
35431         return ret_arr;
35432 }
35433
35434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35435         LDKQueryChannelRange this_ptr_conv;
35436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35437         this_ptr_conv.is_owned = false;
35438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35439         LDKThirtyTwoBytes val_ref;
35440         CHECK((*env)->GetArrayLength(env, val) == 32);
35441         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35442         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
35443 }
35444
35445 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
35446         LDKQueryChannelRange this_ptr_conv;
35447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35448         this_ptr_conv.is_owned = false;
35449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35450         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
35451         return ret_conv;
35452 }
35453
35454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35455         LDKQueryChannelRange this_ptr_conv;
35456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35457         this_ptr_conv.is_owned = false;
35458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35459         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
35460 }
35461
35462 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
35463         LDKQueryChannelRange 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         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
35468         return ret_conv;
35469 }
35470
35471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35472         LDKQueryChannelRange this_ptr_conv;
35473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35474         this_ptr_conv.is_owned = false;
35475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35476         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
35477 }
35478
35479 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) {
35480         LDKThirtyTwoBytes chain_hash_arg_ref;
35481         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35482         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35483         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
35484         int64_t ret_ref = 0;
35485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35488         ret_ref = (uintptr_t)ret_var.inner;
35489         if (ret_var.is_owned) {
35490                 ret_ref |= 1;
35491         }
35492         return ret_ref;
35493 }
35494
35495 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
35496         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
35497 int64_t ret_ref = 0;
35498 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35499 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35500 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35501 ret_ref = (uintptr_t)ret_var.inner;
35502 if (ret_var.is_owned) {
35503         ret_ref |= 1;
35504 }
35505         return ret_ref;
35506 }
35507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35508         LDKQueryChannelRange arg_conv;
35509         arg_conv.inner = (void*)(arg & (~1));
35510         arg_conv.is_owned = false;
35511         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35512         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
35513         return ret_conv;
35514 }
35515
35516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35517         LDKQueryChannelRange orig_conv;
35518         orig_conv.inner = (void*)(orig & (~1));
35519         orig_conv.is_owned = false;
35520         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35521         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
35522         int64_t ret_ref = 0;
35523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35526         ret_ref = (uintptr_t)ret_var.inner;
35527         if (ret_var.is_owned) {
35528                 ret_ref |= 1;
35529         }
35530         return ret_ref;
35531 }
35532
35533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35534         LDKReplyChannelRange this_obj_conv;
35535         this_obj_conv.inner = (void*)(this_obj & (~1));
35536         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35538         ReplyChannelRange_free(this_obj_conv);
35539 }
35540
35541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35542         LDKReplyChannelRange this_ptr_conv;
35543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35544         this_ptr_conv.is_owned = false;
35545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35546         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35547         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
35548         return ret_arr;
35549 }
35550
35551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35552         LDKReplyChannelRange this_ptr_conv;
35553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35554         this_ptr_conv.is_owned = false;
35555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35556         LDKThirtyTwoBytes val_ref;
35557         CHECK((*env)->GetArrayLength(env, val) == 32);
35558         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35559         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
35560 }
35561
35562 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
35563         LDKReplyChannelRange this_ptr_conv;
35564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35565         this_ptr_conv.is_owned = false;
35566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35567         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
35568         return ret_conv;
35569 }
35570
35571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35572         LDKReplyChannelRange this_ptr_conv;
35573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35574         this_ptr_conv.is_owned = false;
35575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35576         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
35577 }
35578
35579 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
35580         LDKReplyChannelRange this_ptr_conv;
35581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35582         this_ptr_conv.is_owned = false;
35583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35584         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
35585         return ret_conv;
35586 }
35587
35588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35589         LDKReplyChannelRange this_ptr_conv;
35590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35591         this_ptr_conv.is_owned = false;
35592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35593         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
35594 }
35595
35596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
35597         LDKReplyChannelRange this_ptr_conv;
35598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35599         this_ptr_conv.is_owned = false;
35600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35601         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
35602         return ret_conv;
35603 }
35604
35605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
35606         LDKReplyChannelRange this_ptr_conv;
35607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35608         this_ptr_conv.is_owned = false;
35609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35610         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
35611 }
35612
35613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35614         LDKReplyChannelRange this_ptr_conv;
35615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35616         this_ptr_conv.is_owned = false;
35617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35618         LDKCVec_u64Z val_constr;
35619         val_constr.datalen = (*env)->GetArrayLength(env, val);
35620         if (val_constr.datalen > 0)
35621                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35622         else
35623                 val_constr.data = NULL;
35624         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35625         for (size_t g = 0; g < val_constr.datalen; g++) {
35626                 int64_t val_conv_6 = val_vals[g];
35627                 val_constr.data[g] = val_conv_6;
35628         }
35629         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35630         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
35631 }
35632
35633 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) {
35634         LDKThirtyTwoBytes chain_hash_arg_ref;
35635         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35636         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35637         LDKCVec_u64Z short_channel_ids_arg_constr;
35638         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
35639         if (short_channel_ids_arg_constr.datalen > 0)
35640                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35641         else
35642                 short_channel_ids_arg_constr.data = NULL;
35643         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
35644         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
35645                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
35646                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
35647         }
35648         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
35649         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
35650         int64_t ret_ref = 0;
35651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35654         ret_ref = (uintptr_t)ret_var.inner;
35655         if (ret_var.is_owned) {
35656                 ret_ref |= 1;
35657         }
35658         return ret_ref;
35659 }
35660
35661 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
35662         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
35663 int64_t ret_ref = 0;
35664 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35665 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35666 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35667 ret_ref = (uintptr_t)ret_var.inner;
35668 if (ret_var.is_owned) {
35669         ret_ref |= 1;
35670 }
35671         return ret_ref;
35672 }
35673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35674         LDKReplyChannelRange arg_conv;
35675         arg_conv.inner = (void*)(arg & (~1));
35676         arg_conv.is_owned = false;
35677         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35678         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
35679         return ret_conv;
35680 }
35681
35682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35683         LDKReplyChannelRange orig_conv;
35684         orig_conv.inner = (void*)(orig & (~1));
35685         orig_conv.is_owned = false;
35686         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35687         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
35688         int64_t ret_ref = 0;
35689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35692         ret_ref = (uintptr_t)ret_var.inner;
35693         if (ret_var.is_owned) {
35694                 ret_ref |= 1;
35695         }
35696         return ret_ref;
35697 }
35698
35699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35700         LDKQueryShortChannelIds this_obj_conv;
35701         this_obj_conv.inner = (void*)(this_obj & (~1));
35702         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35704         QueryShortChannelIds_free(this_obj_conv);
35705 }
35706
35707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35708         LDKQueryShortChannelIds this_ptr_conv;
35709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35710         this_ptr_conv.is_owned = false;
35711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35712         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35713         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
35714         return ret_arr;
35715 }
35716
35717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35718         LDKQueryShortChannelIds this_ptr_conv;
35719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35720         this_ptr_conv.is_owned = false;
35721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35722         LDKThirtyTwoBytes val_ref;
35723         CHECK((*env)->GetArrayLength(env, val) == 32);
35724         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35725         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
35726 }
35727
35728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35729         LDKQueryShortChannelIds this_ptr_conv;
35730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35731         this_ptr_conv.is_owned = false;
35732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35733         LDKCVec_u64Z val_constr;
35734         val_constr.datalen = (*env)->GetArrayLength(env, val);
35735         if (val_constr.datalen > 0)
35736                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35737         else
35738                 val_constr.data = NULL;
35739         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35740         for (size_t g = 0; g < val_constr.datalen; g++) {
35741                 int64_t val_conv_6 = val_vals[g];
35742                 val_constr.data[g] = val_conv_6;
35743         }
35744         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35745         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
35746 }
35747
35748 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) {
35749         LDKThirtyTwoBytes chain_hash_arg_ref;
35750         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35751         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35752         LDKCVec_u64Z short_channel_ids_arg_constr;
35753         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
35754         if (short_channel_ids_arg_constr.datalen > 0)
35755                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35756         else
35757                 short_channel_ids_arg_constr.data = NULL;
35758         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
35759         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
35760                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
35761                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
35762         }
35763         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
35764         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
35765         int64_t ret_ref = 0;
35766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35769         ret_ref = (uintptr_t)ret_var.inner;
35770         if (ret_var.is_owned) {
35771                 ret_ref |= 1;
35772         }
35773         return ret_ref;
35774 }
35775
35776 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
35777         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
35778 int64_t ret_ref = 0;
35779 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35780 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35781 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35782 ret_ref = (uintptr_t)ret_var.inner;
35783 if (ret_var.is_owned) {
35784         ret_ref |= 1;
35785 }
35786         return ret_ref;
35787 }
35788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35789         LDKQueryShortChannelIds arg_conv;
35790         arg_conv.inner = (void*)(arg & (~1));
35791         arg_conv.is_owned = false;
35792         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35793         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
35794         return ret_conv;
35795 }
35796
35797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35798         LDKQueryShortChannelIds orig_conv;
35799         orig_conv.inner = (void*)(orig & (~1));
35800         orig_conv.is_owned = false;
35801         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35802         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
35803         int64_t ret_ref = 0;
35804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35807         ret_ref = (uintptr_t)ret_var.inner;
35808         if (ret_var.is_owned) {
35809                 ret_ref |= 1;
35810         }
35811         return ret_ref;
35812 }
35813
35814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35815         LDKReplyShortChannelIdsEnd this_obj_conv;
35816         this_obj_conv.inner = (void*)(this_obj & (~1));
35817         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35819         ReplyShortChannelIdsEnd_free(this_obj_conv);
35820 }
35821
35822 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35823         LDKReplyShortChannelIdsEnd this_ptr_conv;
35824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35825         this_ptr_conv.is_owned = false;
35826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35827         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35828         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
35829         return ret_arr;
35830 }
35831
35832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35833         LDKReplyShortChannelIdsEnd this_ptr_conv;
35834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35835         this_ptr_conv.is_owned = false;
35836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35837         LDKThirtyTwoBytes val_ref;
35838         CHECK((*env)->GetArrayLength(env, val) == 32);
35839         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35840         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
35841 }
35842
35843 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
35844         LDKReplyShortChannelIdsEnd this_ptr_conv;
35845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35846         this_ptr_conv.is_owned = false;
35847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35848         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
35849         return ret_conv;
35850 }
35851
35852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
35853         LDKReplyShortChannelIdsEnd this_ptr_conv;
35854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35855         this_ptr_conv.is_owned = false;
35856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35857         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
35858 }
35859
35860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
35861         LDKThirtyTwoBytes chain_hash_arg_ref;
35862         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35863         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35864         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
35865         int64_t ret_ref = 0;
35866         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35867         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35869         ret_ref = (uintptr_t)ret_var.inner;
35870         if (ret_var.is_owned) {
35871                 ret_ref |= 1;
35872         }
35873         return ret_ref;
35874 }
35875
35876 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
35877         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
35878 int64_t ret_ref = 0;
35879 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35880 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35881 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35882 ret_ref = (uintptr_t)ret_var.inner;
35883 if (ret_var.is_owned) {
35884         ret_ref |= 1;
35885 }
35886         return ret_ref;
35887 }
35888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35889         LDKReplyShortChannelIdsEnd arg_conv;
35890         arg_conv.inner = (void*)(arg & (~1));
35891         arg_conv.is_owned = false;
35892         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35893         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
35894         return ret_conv;
35895 }
35896
35897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35898         LDKReplyShortChannelIdsEnd orig_conv;
35899         orig_conv.inner = (void*)(orig & (~1));
35900         orig_conv.is_owned = false;
35901         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35902         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
35903         int64_t ret_ref = 0;
35904         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35905         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35907         ret_ref = (uintptr_t)ret_var.inner;
35908         if (ret_var.is_owned) {
35909                 ret_ref |= 1;
35910         }
35911         return ret_ref;
35912 }
35913
35914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35915         LDKGossipTimestampFilter this_obj_conv;
35916         this_obj_conv.inner = (void*)(this_obj & (~1));
35917         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35919         GossipTimestampFilter_free(this_obj_conv);
35920 }
35921
35922 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35923         LDKGossipTimestampFilter this_ptr_conv;
35924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35925         this_ptr_conv.is_owned = false;
35926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35927         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35928         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
35929         return ret_arr;
35930 }
35931
35932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35933         LDKGossipTimestampFilter this_ptr_conv;
35934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35935         this_ptr_conv.is_owned = false;
35936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35937         LDKThirtyTwoBytes val_ref;
35938         CHECK((*env)->GetArrayLength(env, val) == 32);
35939         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35940         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
35941 }
35942
35943 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35944         LDKGossipTimestampFilter this_ptr_conv;
35945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35946         this_ptr_conv.is_owned = false;
35947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35948         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
35949         return ret_conv;
35950 }
35951
35952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35953         LDKGossipTimestampFilter this_ptr_conv;
35954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35955         this_ptr_conv.is_owned = false;
35956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35957         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
35958 }
35959
35960 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
35961         LDKGossipTimestampFilter this_ptr_conv;
35962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35963         this_ptr_conv.is_owned = false;
35964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35965         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
35966         return ret_conv;
35967 }
35968
35969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35970         LDKGossipTimestampFilter this_ptr_conv;
35971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35972         this_ptr_conv.is_owned = false;
35973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35974         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
35975 }
35976
35977 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) {
35978         LDKThirtyTwoBytes chain_hash_arg_ref;
35979         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
35980         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
35981         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
35982         int64_t ret_ref = 0;
35983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35986         ret_ref = (uintptr_t)ret_var.inner;
35987         if (ret_var.is_owned) {
35988                 ret_ref |= 1;
35989         }
35990         return ret_ref;
35991 }
35992
35993 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
35994         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
35995 int64_t ret_ref = 0;
35996 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35997 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35998 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35999 ret_ref = (uintptr_t)ret_var.inner;
36000 if (ret_var.is_owned) {
36001         ret_ref |= 1;
36002 }
36003         return ret_ref;
36004 }
36005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36006         LDKGossipTimestampFilter arg_conv;
36007         arg_conv.inner = (void*)(arg & (~1));
36008         arg_conv.is_owned = false;
36009         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36010         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
36011         return ret_conv;
36012 }
36013
36014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36015         LDKGossipTimestampFilter orig_conv;
36016         orig_conv.inner = (void*)(orig & (~1));
36017         orig_conv.is_owned = false;
36018         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36019         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
36020         int64_t ret_ref = 0;
36021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36024         ret_ref = (uintptr_t)ret_var.inner;
36025         if (ret_var.is_owned) {
36026                 ret_ref |= 1;
36027         }
36028         return ret_ref;
36029 }
36030
36031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36032         if ((this_ptr & 1) != 0) return;
36033         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36034         CHECK_ACCESS(this_ptr_ptr);
36035         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
36036         FREE((void*)this_ptr);
36037         ErrorAction_free(this_ptr_conv);
36038 }
36039
36040 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
36041         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36042         *ret_copy = ErrorAction_clone(arg);
36043 int64_t ret_ref = (uintptr_t)ret_copy;
36044         return ret_ref;
36045 }
36046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36047         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
36048         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
36049         return ret_conv;
36050 }
36051
36052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36053         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
36054         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36055         *ret_copy = ErrorAction_clone(orig_conv);
36056         int64_t ret_ref = (uintptr_t)ret_copy;
36057         return ret_ref;
36058 }
36059
36060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
36061         LDKErrorMessage msg_conv;
36062         msg_conv.inner = (void*)(msg & (~1));
36063         msg_conv.is_owned = (msg & 1) || (msg == 0);
36064         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36065         msg_conv = ErrorMessage_clone(&msg_conv);
36066         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36067         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
36068         int64_t ret_ref = (uintptr_t)ret_copy;
36069         return ret_ref;
36070 }
36071
36072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
36073         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36074         *ret_copy = ErrorAction_ignore_error();
36075         int64_t ret_ref = (uintptr_t)ret_copy;
36076         return ret_ref;
36077 }
36078
36079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
36080         LDKLevel a_conv = LDKLevel_from_java(env, a);
36081         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36082         *ret_copy = ErrorAction_ignore_and_log(a_conv);
36083         int64_t ret_ref = (uintptr_t)ret_copy;
36084         return ret_ref;
36085 }
36086
36087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
36088         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36089         *ret_copy = ErrorAction_ignore_duplicate_gossip();
36090         int64_t ret_ref = (uintptr_t)ret_copy;
36091         return ret_ref;
36092 }
36093
36094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
36095         LDKErrorMessage msg_conv;
36096         msg_conv.inner = (void*)(msg & (~1));
36097         msg_conv.is_owned = (msg & 1) || (msg == 0);
36098         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36099         msg_conv = ErrorMessage_clone(&msg_conv);
36100         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36101         *ret_copy = ErrorAction_send_error_message(msg_conv);
36102         int64_t ret_ref = (uintptr_t)ret_copy;
36103         return ret_ref;
36104 }
36105
36106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
36107         LDKWarningMessage msg_conv;
36108         msg_conv.inner = (void*)(msg & (~1));
36109         msg_conv.is_owned = (msg & 1) || (msg == 0);
36110         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36111         msg_conv = WarningMessage_clone(&msg_conv);
36112         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
36113         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36114         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
36115         int64_t ret_ref = (uintptr_t)ret_copy;
36116         return ret_ref;
36117 }
36118
36119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36120         LDKLightningError this_obj_conv;
36121         this_obj_conv.inner = (void*)(this_obj & (~1));
36122         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36124         LightningError_free(this_obj_conv);
36125 }
36126
36127 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
36128         LDKLightningError this_ptr_conv;
36129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36130         this_ptr_conv.is_owned = false;
36131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36132         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
36133         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
36134         Str_free(ret_str);
36135         return ret_conv;
36136 }
36137
36138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
36139         LDKLightningError this_ptr_conv;
36140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36141         this_ptr_conv.is_owned = false;
36142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36143         LDKStr val_conv = java_to_owned_str(env, val);
36144         LightningError_set_err(&this_ptr_conv, val_conv);
36145 }
36146
36147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
36148         LDKLightningError this_ptr_conv;
36149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36150         this_ptr_conv.is_owned = false;
36151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36152         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
36153         *ret_copy = LightningError_get_action(&this_ptr_conv);
36154         int64_t ret_ref = (uintptr_t)ret_copy;
36155         return ret_ref;
36156 }
36157
36158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36159         LDKLightningError this_ptr_conv;
36160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36161         this_ptr_conv.is_owned = false;
36162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36163         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36164         CHECK_ACCESS(val_ptr);
36165         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
36166         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
36167         LightningError_set_action(&this_ptr_conv, val_conv);
36168 }
36169
36170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
36171         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
36172         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
36173         CHECK_ACCESS(action_arg_ptr);
36174         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
36175         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
36176         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
36177         int64_t ret_ref = 0;
36178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36181         ret_ref = (uintptr_t)ret_var.inner;
36182         if (ret_var.is_owned) {
36183                 ret_ref |= 1;
36184         }
36185         return ret_ref;
36186 }
36187
36188 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
36189         LDKLightningError ret_var = LightningError_clone(arg);
36190 int64_t ret_ref = 0;
36191 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36192 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36193 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36194 ret_ref = (uintptr_t)ret_var.inner;
36195 if (ret_var.is_owned) {
36196         ret_ref |= 1;
36197 }
36198         return ret_ref;
36199 }
36200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36201         LDKLightningError arg_conv;
36202         arg_conv.inner = (void*)(arg & (~1));
36203         arg_conv.is_owned = false;
36204         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36205         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
36206         return ret_conv;
36207 }
36208
36209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36210         LDKLightningError orig_conv;
36211         orig_conv.inner = (void*)(orig & (~1));
36212         orig_conv.is_owned = false;
36213         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36214         LDKLightningError ret_var = LightningError_clone(&orig_conv);
36215         int64_t ret_ref = 0;
36216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36219         ret_ref = (uintptr_t)ret_var.inner;
36220         if (ret_var.is_owned) {
36221                 ret_ref |= 1;
36222         }
36223         return ret_ref;
36224 }
36225
36226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36227         LDKCommitmentUpdate this_obj_conv;
36228         this_obj_conv.inner = (void*)(this_obj & (~1));
36229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36231         CommitmentUpdate_free(this_obj_conv);
36232 }
36233
36234 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
36235         LDKCommitmentUpdate this_ptr_conv;
36236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36237         this_ptr_conv.is_owned = false;
36238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36239         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
36240         int64_tArray ret_arr = NULL;
36241         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36242         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36243         for (size_t p = 0; p < ret_var.datalen; p++) {
36244                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
36245                 int64_t ret_conv_15_ref = 0;
36246                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36247                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36248                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
36249                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
36250                 if (ret_conv_15_var.is_owned) {
36251                         ret_conv_15_ref |= 1;
36252                 }
36253                 ret_arr_ptr[p] = ret_conv_15_ref;
36254         }
36255         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36256         FREE(ret_var.data);
36257         return ret_arr;
36258 }
36259
36260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36261         LDKCommitmentUpdate this_ptr_conv;
36262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36263         this_ptr_conv.is_owned = false;
36264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36265         LDKCVec_UpdateAddHTLCZ val_constr;
36266         val_constr.datalen = (*env)->GetArrayLength(env, val);
36267         if (val_constr.datalen > 0)
36268                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
36269         else
36270                 val_constr.data = NULL;
36271         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36272         for (size_t p = 0; p < val_constr.datalen; p++) {
36273                 int64_t val_conv_15 = val_vals[p];
36274                 LDKUpdateAddHTLC val_conv_15_conv;
36275                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
36276                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
36277                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
36278                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
36279                 val_constr.data[p] = val_conv_15_conv;
36280         }
36281         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36282         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
36283 }
36284
36285 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
36286         LDKCommitmentUpdate this_ptr_conv;
36287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36288         this_ptr_conv.is_owned = false;
36289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36290         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
36291         int64_tArray ret_arr = NULL;
36292         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36293         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36294         for (size_t t = 0; t < ret_var.datalen; t++) {
36295                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
36296                 int64_t ret_conv_19_ref = 0;
36297                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36298                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36299                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
36300                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
36301                 if (ret_conv_19_var.is_owned) {
36302                         ret_conv_19_ref |= 1;
36303                 }
36304                 ret_arr_ptr[t] = ret_conv_19_ref;
36305         }
36306         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36307         FREE(ret_var.data);
36308         return ret_arr;
36309 }
36310
36311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36312         LDKCommitmentUpdate this_ptr_conv;
36313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36314         this_ptr_conv.is_owned = false;
36315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36316         LDKCVec_UpdateFulfillHTLCZ val_constr;
36317         val_constr.datalen = (*env)->GetArrayLength(env, val);
36318         if (val_constr.datalen > 0)
36319                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
36320         else
36321                 val_constr.data = NULL;
36322         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36323         for (size_t t = 0; t < val_constr.datalen; t++) {
36324                 int64_t val_conv_19 = val_vals[t];
36325                 LDKUpdateFulfillHTLC val_conv_19_conv;
36326                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
36327                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
36328                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
36329                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
36330                 val_constr.data[t] = val_conv_19_conv;
36331         }
36332         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36333         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
36334 }
36335
36336 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
36337         LDKCommitmentUpdate this_ptr_conv;
36338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36339         this_ptr_conv.is_owned = false;
36340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36341         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
36342         int64_tArray ret_arr = NULL;
36343         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36344         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36345         for (size_t q = 0; q < ret_var.datalen; q++) {
36346                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
36347                 int64_t ret_conv_16_ref = 0;
36348                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36349                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36350                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
36351                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
36352                 if (ret_conv_16_var.is_owned) {
36353                         ret_conv_16_ref |= 1;
36354                 }
36355                 ret_arr_ptr[q] = ret_conv_16_ref;
36356         }
36357         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36358         FREE(ret_var.data);
36359         return ret_arr;
36360 }
36361
36362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36363         LDKCommitmentUpdate this_ptr_conv;
36364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36365         this_ptr_conv.is_owned = false;
36366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36367         LDKCVec_UpdateFailHTLCZ val_constr;
36368         val_constr.datalen = (*env)->GetArrayLength(env, val);
36369         if (val_constr.datalen > 0)
36370                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
36371         else
36372                 val_constr.data = NULL;
36373         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36374         for (size_t q = 0; q < val_constr.datalen; q++) {
36375                 int64_t val_conv_16 = val_vals[q];
36376                 LDKUpdateFailHTLC val_conv_16_conv;
36377                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
36378                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
36379                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
36380                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
36381                 val_constr.data[q] = val_conv_16_conv;
36382         }
36383         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36384         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
36385 }
36386
36387 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
36388         LDKCommitmentUpdate this_ptr_conv;
36389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36390         this_ptr_conv.is_owned = false;
36391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36392         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
36393         int64_tArray ret_arr = NULL;
36394         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36395         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36396         for (size_t z = 0; z < ret_var.datalen; z++) {
36397                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
36398                 int64_t ret_conv_25_ref = 0;
36399                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36400                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36401                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
36402                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
36403                 if (ret_conv_25_var.is_owned) {
36404                         ret_conv_25_ref |= 1;
36405                 }
36406                 ret_arr_ptr[z] = ret_conv_25_ref;
36407         }
36408         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36409         FREE(ret_var.data);
36410         return ret_arr;
36411 }
36412
36413 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) {
36414         LDKCommitmentUpdate this_ptr_conv;
36415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36416         this_ptr_conv.is_owned = false;
36417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36418         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
36419         val_constr.datalen = (*env)->GetArrayLength(env, val);
36420         if (val_constr.datalen > 0)
36421                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
36422         else
36423                 val_constr.data = NULL;
36424         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36425         for (size_t z = 0; z < val_constr.datalen; z++) {
36426                 int64_t val_conv_25 = val_vals[z];
36427                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
36428                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
36429                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
36430                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
36431                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
36432                 val_constr.data[z] = val_conv_25_conv;
36433         }
36434         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36435         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
36436 }
36437
36438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
36439         LDKCommitmentUpdate this_ptr_conv;
36440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36441         this_ptr_conv.is_owned = false;
36442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36443         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
36444         int64_t ret_ref = 0;
36445         if ((uintptr_t)ret_var.inner > 4096) {
36446                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36447                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36449                 ret_ref = (uintptr_t)ret_var.inner;
36450                 if (ret_var.is_owned) {
36451                         ret_ref |= 1;
36452                 }
36453         }
36454         return ret_ref;
36455 }
36456
36457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36458         LDKCommitmentUpdate this_ptr_conv;
36459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36460         this_ptr_conv.is_owned = false;
36461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36462         LDKUpdateFee val_conv;
36463         val_conv.inner = (void*)(val & (~1));
36464         val_conv.is_owned = (val & 1) || (val == 0);
36465         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36466         val_conv = UpdateFee_clone(&val_conv);
36467         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
36468 }
36469
36470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
36471         LDKCommitmentUpdate this_ptr_conv;
36472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36473         this_ptr_conv.is_owned = false;
36474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36475         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
36476         int64_t ret_ref = 0;
36477         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36478         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36480         ret_ref = (uintptr_t)ret_var.inner;
36481         if (ret_var.is_owned) {
36482                 ret_ref |= 1;
36483         }
36484         return ret_ref;
36485 }
36486
36487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36488         LDKCommitmentUpdate this_ptr_conv;
36489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36490         this_ptr_conv.is_owned = false;
36491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36492         LDKCommitmentSigned val_conv;
36493         val_conv.inner = (void*)(val & (~1));
36494         val_conv.is_owned = (val & 1) || (val == 0);
36495         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36496         val_conv = CommitmentSigned_clone(&val_conv);
36497         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
36498 }
36499
36500 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) {
36501         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
36502         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
36503         if (update_add_htlcs_arg_constr.datalen > 0)
36504                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
36505         else
36506                 update_add_htlcs_arg_constr.data = NULL;
36507         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
36508         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
36509                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
36510                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
36511                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
36512                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
36513                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
36514                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
36515                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
36516         }
36517         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
36518         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
36519         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
36520         if (update_fulfill_htlcs_arg_constr.datalen > 0)
36521                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
36522         else
36523                 update_fulfill_htlcs_arg_constr.data = NULL;
36524         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
36525         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
36526                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
36527                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
36528                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
36529                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
36530                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
36531                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
36532                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
36533         }
36534         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
36535         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
36536         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
36537         if (update_fail_htlcs_arg_constr.datalen > 0)
36538                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
36539         else
36540                 update_fail_htlcs_arg_constr.data = NULL;
36541         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
36542         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
36543                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
36544                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
36545                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
36546                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
36547                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
36548                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
36549                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
36550         }
36551         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
36552         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
36553         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
36554         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
36555                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
36556         else
36557                 update_fail_malformed_htlcs_arg_constr.data = NULL;
36558         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
36559         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
36560                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
36561                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
36562                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
36563                 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);
36564                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
36565                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
36566                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
36567         }
36568         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
36569         LDKUpdateFee update_fee_arg_conv;
36570         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
36571         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
36572         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
36573         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
36574         LDKCommitmentSigned commitment_signed_arg_conv;
36575         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
36576         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
36577         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
36578         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
36579         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);
36580         int64_t ret_ref = 0;
36581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36584         ret_ref = (uintptr_t)ret_var.inner;
36585         if (ret_var.is_owned) {
36586                 ret_ref |= 1;
36587         }
36588         return ret_ref;
36589 }
36590
36591 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
36592         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
36593 int64_t ret_ref = 0;
36594 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36595 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36596 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36597 ret_ref = (uintptr_t)ret_var.inner;
36598 if (ret_var.is_owned) {
36599         ret_ref |= 1;
36600 }
36601         return ret_ref;
36602 }
36603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36604         LDKCommitmentUpdate arg_conv;
36605         arg_conv.inner = (void*)(arg & (~1));
36606         arg_conv.is_owned = false;
36607         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36608         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
36609         return ret_conv;
36610 }
36611
36612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36613         LDKCommitmentUpdate orig_conv;
36614         orig_conv.inner = (void*)(orig & (~1));
36615         orig_conv.is_owned = false;
36616         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36617         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
36618         int64_t ret_ref = 0;
36619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36622         ret_ref = (uintptr_t)ret_var.inner;
36623         if (ret_var.is_owned) {
36624                 ret_ref |= 1;
36625         }
36626         return ret_ref;
36627 }
36628
36629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36630         if ((this_ptr & 1) != 0) return;
36631         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36632         CHECK_ACCESS(this_ptr_ptr);
36633         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
36634         FREE((void*)this_ptr);
36635         ChannelMessageHandler_free(this_ptr_conv);
36636 }
36637
36638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36639         if ((this_ptr & 1) != 0) return;
36640         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36641         CHECK_ACCESS(this_ptr_ptr);
36642         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
36643         FREE((void*)this_ptr);
36644         RoutingMessageHandler_free(this_ptr_conv);
36645 }
36646
36647 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
36648         LDKAcceptChannel obj_conv;
36649         obj_conv.inner = (void*)(obj & (~1));
36650         obj_conv.is_owned = false;
36651         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36652         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
36653         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36654         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36655         CVec_u8Z_free(ret_var);
36656         return ret_arr;
36657 }
36658
36659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36660         LDKu8slice ser_ref;
36661         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36662         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36663         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
36664         *ret_conv = AcceptChannel_read(ser_ref);
36665         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36666         return (int64_t)ret_conv;
36667 }
36668
36669 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
36670         LDKAnnouncementSignatures obj_conv;
36671         obj_conv.inner = (void*)(obj & (~1));
36672         obj_conv.is_owned = false;
36673         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36674         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
36675         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36676         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36677         CVec_u8Z_free(ret_var);
36678         return ret_arr;
36679 }
36680
36681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36682         LDKu8slice ser_ref;
36683         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36684         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36685         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
36686         *ret_conv = AnnouncementSignatures_read(ser_ref);
36687         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36688         return (int64_t)ret_conv;
36689 }
36690
36691 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
36692         LDKChannelReestablish obj_conv;
36693         obj_conv.inner = (void*)(obj & (~1));
36694         obj_conv.is_owned = false;
36695         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36696         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
36697         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36698         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36699         CVec_u8Z_free(ret_var);
36700         return ret_arr;
36701 }
36702
36703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36704         LDKu8slice ser_ref;
36705         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36706         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36707         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
36708         *ret_conv = ChannelReestablish_read(ser_ref);
36709         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36710         return (int64_t)ret_conv;
36711 }
36712
36713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
36714         LDKClosingSigned obj_conv;
36715         obj_conv.inner = (void*)(obj & (~1));
36716         obj_conv.is_owned = false;
36717         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36718         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
36719         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36720         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36721         CVec_u8Z_free(ret_var);
36722         return ret_arr;
36723 }
36724
36725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36726         LDKu8slice ser_ref;
36727         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36728         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36729         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
36730         *ret_conv = ClosingSigned_read(ser_ref);
36731         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36732         return (int64_t)ret_conv;
36733 }
36734
36735 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36736         LDKClosingSignedFeeRange obj_conv;
36737         obj_conv.inner = (void*)(obj & (~1));
36738         obj_conv.is_owned = false;
36739         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36740         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
36741         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36742         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36743         CVec_u8Z_free(ret_var);
36744         return ret_arr;
36745 }
36746
36747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36748         LDKu8slice ser_ref;
36749         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36750         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36751         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
36752         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
36753         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36754         return (int64_t)ret_conv;
36755 }
36756
36757 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
36758         LDKCommitmentSigned obj_conv;
36759         obj_conv.inner = (void*)(obj & (~1));
36760         obj_conv.is_owned = false;
36761         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36762         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
36763         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36764         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36765         CVec_u8Z_free(ret_var);
36766         return ret_arr;
36767 }
36768
36769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36770         LDKu8slice ser_ref;
36771         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36772         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36773         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
36774         *ret_conv = CommitmentSigned_read(ser_ref);
36775         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36776         return (int64_t)ret_conv;
36777 }
36778
36779 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
36780         LDKFundingCreated obj_conv;
36781         obj_conv.inner = (void*)(obj & (~1));
36782         obj_conv.is_owned = false;
36783         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36784         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
36785         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36786         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36787         CVec_u8Z_free(ret_var);
36788         return ret_arr;
36789 }
36790
36791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36792         LDKu8slice ser_ref;
36793         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36794         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36795         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
36796         *ret_conv = FundingCreated_read(ser_ref);
36797         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36798         return (int64_t)ret_conv;
36799 }
36800
36801 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
36802         LDKFundingSigned obj_conv;
36803         obj_conv.inner = (void*)(obj & (~1));
36804         obj_conv.is_owned = false;
36805         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36806         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
36807         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36808         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36809         CVec_u8Z_free(ret_var);
36810         return ret_arr;
36811 }
36812
36813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36814         LDKu8slice ser_ref;
36815         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36816         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36817         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
36818         *ret_conv = FundingSigned_read(ser_ref);
36819         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36820         return (int64_t)ret_conv;
36821 }
36822
36823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
36824         LDKChannelReady obj_conv;
36825         obj_conv.inner = (void*)(obj & (~1));
36826         obj_conv.is_owned = false;
36827         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36828         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
36829         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36830         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36831         CVec_u8Z_free(ret_var);
36832         return ret_arr;
36833 }
36834
36835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36836         LDKu8slice ser_ref;
36837         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36838         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36839         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
36840         *ret_conv = ChannelReady_read(ser_ref);
36841         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36842         return (int64_t)ret_conv;
36843 }
36844
36845 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
36846         LDKInit obj_conv;
36847         obj_conv.inner = (void*)(obj & (~1));
36848         obj_conv.is_owned = false;
36849         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36850         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
36851         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36852         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36853         CVec_u8Z_free(ret_var);
36854         return ret_arr;
36855 }
36856
36857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36858         LDKu8slice ser_ref;
36859         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36860         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36861         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
36862         *ret_conv = Init_read(ser_ref);
36863         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36864         return (int64_t)ret_conv;
36865 }
36866
36867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
36868         LDKOpenChannel obj_conv;
36869         obj_conv.inner = (void*)(obj & (~1));
36870         obj_conv.is_owned = false;
36871         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36872         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
36873         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36874         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36875         CVec_u8Z_free(ret_var);
36876         return ret_arr;
36877 }
36878
36879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36880         LDKu8slice ser_ref;
36881         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36882         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36883         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
36884         *ret_conv = OpenChannel_read(ser_ref);
36885         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36886         return (int64_t)ret_conv;
36887 }
36888
36889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
36890         LDKRevokeAndACK obj_conv;
36891         obj_conv.inner = (void*)(obj & (~1));
36892         obj_conv.is_owned = false;
36893         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36894         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
36895         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36896         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36897         CVec_u8Z_free(ret_var);
36898         return ret_arr;
36899 }
36900
36901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36902         LDKu8slice ser_ref;
36903         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36904         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36905         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
36906         *ret_conv = RevokeAndACK_read(ser_ref);
36907         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36908         return (int64_t)ret_conv;
36909 }
36910
36911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
36912         LDKShutdown obj_conv;
36913         obj_conv.inner = (void*)(obj & (~1));
36914         obj_conv.is_owned = false;
36915         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36916         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
36917         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36918         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36919         CVec_u8Z_free(ret_var);
36920         return ret_arr;
36921 }
36922
36923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36924         LDKu8slice ser_ref;
36925         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36926         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36927         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
36928         *ret_conv = Shutdown_read(ser_ref);
36929         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36930         return (int64_t)ret_conv;
36931 }
36932
36933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36934         LDKUpdateFailHTLC obj_conv;
36935         obj_conv.inner = (void*)(obj & (~1));
36936         obj_conv.is_owned = false;
36937         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36938         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
36939         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36940         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36941         CVec_u8Z_free(ret_var);
36942         return ret_arr;
36943 }
36944
36945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36946         LDKu8slice ser_ref;
36947         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36948         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36949         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
36950         *ret_conv = UpdateFailHTLC_read(ser_ref);
36951         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36952         return (int64_t)ret_conv;
36953 }
36954
36955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
36956         LDKUpdateFailMalformedHTLC obj_conv;
36957         obj_conv.inner = (void*)(obj & (~1));
36958         obj_conv.is_owned = false;
36959         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36960         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
36961         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36962         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36963         CVec_u8Z_free(ret_var);
36964         return ret_arr;
36965 }
36966
36967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36968         LDKu8slice ser_ref;
36969         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36970         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36971         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
36972         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
36973         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36974         return (int64_t)ret_conv;
36975 }
36976
36977 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
36978         LDKUpdateFee obj_conv;
36979         obj_conv.inner = (void*)(obj & (~1));
36980         obj_conv.is_owned = false;
36981         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36982         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
36983         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36984         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36985         CVec_u8Z_free(ret_var);
36986         return ret_arr;
36987 }
36988
36989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36990         LDKu8slice ser_ref;
36991         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36992         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36993         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
36994         *ret_conv = UpdateFee_read(ser_ref);
36995         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36996         return (int64_t)ret_conv;
36997 }
36998
36999 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37000         LDKUpdateFulfillHTLC obj_conv;
37001         obj_conv.inner = (void*)(obj & (~1));
37002         obj_conv.is_owned = false;
37003         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37004         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
37005         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37006         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37007         CVec_u8Z_free(ret_var);
37008         return ret_arr;
37009 }
37010
37011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37012         LDKu8slice ser_ref;
37013         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37014         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37015         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
37016         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
37017         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37018         return (int64_t)ret_conv;
37019 }
37020
37021 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
37022         LDKUpdateAddHTLC obj_conv;
37023         obj_conv.inner = (void*)(obj & (~1));
37024         obj_conv.is_owned = false;
37025         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37026         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
37027         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37028         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37029         CVec_u8Z_free(ret_var);
37030         return ret_arr;
37031 }
37032
37033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37034         LDKu8slice ser_ref;
37035         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37036         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37037         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
37038         *ret_conv = UpdateAddHTLC_read(ser_ref);
37039         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37040         return (int64_t)ret_conv;
37041 }
37042
37043 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
37044         LDKPing obj_conv;
37045         obj_conv.inner = (void*)(obj & (~1));
37046         obj_conv.is_owned = false;
37047         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37048         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
37049         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37050         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37051         CVec_u8Z_free(ret_var);
37052         return ret_arr;
37053 }
37054
37055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37056         LDKu8slice ser_ref;
37057         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37058         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37059         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
37060         *ret_conv = Ping_read(ser_ref);
37061         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37062         return (int64_t)ret_conv;
37063 }
37064
37065 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
37066         LDKPong obj_conv;
37067         obj_conv.inner = (void*)(obj & (~1));
37068         obj_conv.is_owned = false;
37069         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37070         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
37071         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37072         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37073         CVec_u8Z_free(ret_var);
37074         return ret_arr;
37075 }
37076
37077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37078         LDKu8slice ser_ref;
37079         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37080         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37081         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
37082         *ret_conv = Pong_read(ser_ref);
37083         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37084         return (int64_t)ret_conv;
37085 }
37086
37087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37088         LDKUnsignedChannelAnnouncement obj_conv;
37089         obj_conv.inner = (void*)(obj & (~1));
37090         obj_conv.is_owned = false;
37091         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37092         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
37093         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37094         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37095         CVec_u8Z_free(ret_var);
37096         return ret_arr;
37097 }
37098
37099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37100         LDKu8slice ser_ref;
37101         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37102         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37103         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
37104         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
37105         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37106         return (int64_t)ret_conv;
37107 }
37108
37109 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37110         LDKChannelAnnouncement obj_conv;
37111         obj_conv.inner = (void*)(obj & (~1));
37112         obj_conv.is_owned = false;
37113         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37114         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
37115         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37116         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37117         CVec_u8Z_free(ret_var);
37118         return ret_arr;
37119 }
37120
37121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37122         LDKu8slice ser_ref;
37123         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37124         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37125         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
37126         *ret_conv = ChannelAnnouncement_read(ser_ref);
37127         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37128         return (int64_t)ret_conv;
37129 }
37130
37131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
37132         LDKUnsignedChannelUpdate obj_conv;
37133         obj_conv.inner = (void*)(obj & (~1));
37134         obj_conv.is_owned = false;
37135         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37136         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
37137         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37138         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37139         CVec_u8Z_free(ret_var);
37140         return ret_arr;
37141 }
37142
37143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37144         LDKu8slice ser_ref;
37145         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37146         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37147         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
37148         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
37149         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37150         return (int64_t)ret_conv;
37151 }
37152
37153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
37154         LDKChannelUpdate obj_conv;
37155         obj_conv.inner = (void*)(obj & (~1));
37156         obj_conv.is_owned = false;
37157         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37158         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
37159         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37160         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37161         CVec_u8Z_free(ret_var);
37162         return ret_arr;
37163 }
37164
37165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37166         LDKu8slice ser_ref;
37167         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37168         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37169         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
37170         *ret_conv = ChannelUpdate_read(ser_ref);
37171         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37172         return (int64_t)ret_conv;
37173 }
37174
37175 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
37176         LDKErrorMessage obj_conv;
37177         obj_conv.inner = (void*)(obj & (~1));
37178         obj_conv.is_owned = false;
37179         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37180         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
37181         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37182         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37183         CVec_u8Z_free(ret_var);
37184         return ret_arr;
37185 }
37186
37187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37188         LDKu8slice ser_ref;
37189         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37190         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37191         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
37192         *ret_conv = ErrorMessage_read(ser_ref);
37193         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37194         return (int64_t)ret_conv;
37195 }
37196
37197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
37198         LDKWarningMessage obj_conv;
37199         obj_conv.inner = (void*)(obj & (~1));
37200         obj_conv.is_owned = false;
37201         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37202         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
37203         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37204         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37205         CVec_u8Z_free(ret_var);
37206         return ret_arr;
37207 }
37208
37209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37210         LDKu8slice ser_ref;
37211         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37212         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37213         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
37214         *ret_conv = WarningMessage_read(ser_ref);
37215         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37216         return (int64_t)ret_conv;
37217 }
37218
37219 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37220         LDKUnsignedNodeAnnouncement obj_conv;
37221         obj_conv.inner = (void*)(obj & (~1));
37222         obj_conv.is_owned = false;
37223         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37224         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
37225         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37226         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37227         CVec_u8Z_free(ret_var);
37228         return ret_arr;
37229 }
37230
37231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37232         LDKu8slice ser_ref;
37233         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37234         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37235         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
37236         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
37237         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37238         return (int64_t)ret_conv;
37239 }
37240
37241 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
37242         LDKNodeAnnouncement obj_conv;
37243         obj_conv.inner = (void*)(obj & (~1));
37244         obj_conv.is_owned = false;
37245         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37246         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
37247         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37248         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37249         CVec_u8Z_free(ret_var);
37250         return ret_arr;
37251 }
37252
37253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37254         LDKu8slice ser_ref;
37255         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37256         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37257         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
37258         *ret_conv = NodeAnnouncement_read(ser_ref);
37259         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37260         return (int64_t)ret_conv;
37261 }
37262
37263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37264         LDKu8slice ser_ref;
37265         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37266         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37267         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
37268         *ret_conv = QueryShortChannelIds_read(ser_ref);
37269         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37270         return (int64_t)ret_conv;
37271 }
37272
37273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
37274         LDKQueryShortChannelIds obj_conv;
37275         obj_conv.inner = (void*)(obj & (~1));
37276         obj_conv.is_owned = false;
37277         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37278         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
37279         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37280         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37281         CVec_u8Z_free(ret_var);
37282         return ret_arr;
37283 }
37284
37285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
37286         LDKReplyShortChannelIdsEnd obj_conv;
37287         obj_conv.inner = (void*)(obj & (~1));
37288         obj_conv.is_owned = false;
37289         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37290         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
37291         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37292         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37293         CVec_u8Z_free(ret_var);
37294         return ret_arr;
37295 }
37296
37297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37298         LDKu8slice ser_ref;
37299         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37300         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37301         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
37302         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
37303         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37304         return (int64_t)ret_conv;
37305 }
37306
37307 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
37308         LDKQueryChannelRange this_arg_conv;
37309         this_arg_conv.inner = (void*)(this_arg & (~1));
37310         this_arg_conv.is_owned = false;
37311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37312         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
37313         return ret_conv;
37314 }
37315
37316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
37317         LDKQueryChannelRange obj_conv;
37318         obj_conv.inner = (void*)(obj & (~1));
37319         obj_conv.is_owned = false;
37320         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37321         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
37322         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37323         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37324         CVec_u8Z_free(ret_var);
37325         return ret_arr;
37326 }
37327
37328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37329         LDKu8slice ser_ref;
37330         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37331         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37332         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
37333         *ret_conv = QueryChannelRange_read(ser_ref);
37334         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37335         return (int64_t)ret_conv;
37336 }
37337
37338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37339         LDKu8slice ser_ref;
37340         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37341         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37342         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
37343         *ret_conv = ReplyChannelRange_read(ser_ref);
37344         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37345         return (int64_t)ret_conv;
37346 }
37347
37348 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
37349         LDKReplyChannelRange obj_conv;
37350         obj_conv.inner = (void*)(obj & (~1));
37351         obj_conv.is_owned = false;
37352         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37353         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
37354         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37355         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37356         CVec_u8Z_free(ret_var);
37357         return ret_arr;
37358 }
37359
37360 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
37361         LDKGossipTimestampFilter obj_conv;
37362         obj_conv.inner = (void*)(obj & (~1));
37363         obj_conv.is_owned = false;
37364         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37365         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
37366         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37367         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37368         CVec_u8Z_free(ret_var);
37369         return ret_arr;
37370 }
37371
37372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37373         LDKu8slice ser_ref;
37374         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37375         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37376         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
37377         *ret_conv = GossipTimestampFilter_read(ser_ref);
37378         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37379         return (int64_t)ret_conv;
37380 }
37381
37382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37383         if ((this_ptr & 1) != 0) return;
37384         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37385         CHECK_ACCESS(this_ptr_ptr);
37386         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
37387         FREE((void*)this_ptr);
37388         CustomMessageHandler_free(this_ptr_conv);
37389 }
37390
37391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37392         LDKIgnoringMessageHandler this_obj_conv;
37393         this_obj_conv.inner = (void*)(this_obj & (~1));
37394         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37396         IgnoringMessageHandler_free(this_obj_conv);
37397 }
37398
37399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
37400         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
37401         int64_t ret_ref = 0;
37402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37405         ret_ref = (uintptr_t)ret_var.inner;
37406         if (ret_var.is_owned) {
37407                 ret_ref |= 1;
37408         }
37409         return ret_ref;
37410 }
37411
37412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
37413         LDKIgnoringMessageHandler this_arg_conv;
37414         this_arg_conv.inner = (void*)(this_arg & (~1));
37415         this_arg_conv.is_owned = false;
37416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37417         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
37418         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
37419         return (int64_t)ret_ret;
37420 }
37421
37422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
37423         LDKIgnoringMessageHandler this_arg_conv;
37424         this_arg_conv.inner = (void*)(this_arg & (~1));
37425         this_arg_conv.is_owned = false;
37426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37427         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
37428         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
37429         return (int64_t)ret_ret;
37430 }
37431
37432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
37433         LDKIgnoringMessageHandler this_arg_conv;
37434         this_arg_conv.inner = (void*)(this_arg & (~1));
37435         this_arg_conv.is_owned = false;
37436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37437         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
37438         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
37439         return (int64_t)ret_ret;
37440 }
37441
37442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
37443         LDKIgnoringMessageHandler this_arg_conv;
37444         this_arg_conv.inner = (void*)(this_arg & (~1));
37445         this_arg_conv.is_owned = false;
37446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37447         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
37448         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
37449         return (int64_t)ret_ret;
37450 }
37451
37452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37453         LDKErroringMessageHandler this_obj_conv;
37454         this_obj_conv.inner = (void*)(this_obj & (~1));
37455         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37457         ErroringMessageHandler_free(this_obj_conv);
37458 }
37459
37460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
37461         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
37462         int64_t ret_ref = 0;
37463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37466         ret_ref = (uintptr_t)ret_var.inner;
37467         if (ret_var.is_owned) {
37468                 ret_ref |= 1;
37469         }
37470         return ret_ref;
37471 }
37472
37473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
37474         LDKErroringMessageHandler this_arg_conv;
37475         this_arg_conv.inner = (void*)(this_arg & (~1));
37476         this_arg_conv.is_owned = false;
37477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37478         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
37479         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
37480         return (int64_t)ret_ret;
37481 }
37482
37483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
37484         LDKErroringMessageHandler this_arg_conv;
37485         this_arg_conv.inner = (void*)(this_arg & (~1));
37486         this_arg_conv.is_owned = false;
37487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37488         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
37489         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
37490         return (int64_t)ret_ret;
37491 }
37492
37493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37494         LDKMessageHandler this_obj_conv;
37495         this_obj_conv.inner = (void*)(this_obj & (~1));
37496         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37498         MessageHandler_free(this_obj_conv);
37499 }
37500
37501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
37502         LDKMessageHandler this_ptr_conv;
37503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37504         this_ptr_conv.is_owned = false;
37505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37506         // WARNING: This object doesn't live past this scope, needs clone!
37507         int64_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
37508         return ret_ret;
37509 }
37510
37511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37512         LDKMessageHandler this_ptr_conv;
37513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37514         this_ptr_conv.is_owned = false;
37515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37516         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37517         CHECK_ACCESS(val_ptr);
37518         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
37519         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
37520                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37521                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
37522         }
37523         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
37524 }
37525
37526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
37527         LDKMessageHandler this_ptr_conv;
37528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37529         this_ptr_conv.is_owned = false;
37530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37531         // WARNING: This object doesn't live past this scope, needs clone!
37532         int64_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
37533         return ret_ret;
37534 }
37535
37536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37537         LDKMessageHandler this_ptr_conv;
37538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37539         this_ptr_conv.is_owned = false;
37540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37541         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37542         CHECK_ACCESS(val_ptr);
37543         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
37544         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
37545                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37546                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
37547         }
37548         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
37549 }
37550
37551 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) {
37552         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
37553         CHECK_ACCESS(chan_handler_arg_ptr);
37554         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
37555         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
37556                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37557                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
37558         }
37559         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
37560         CHECK_ACCESS(route_handler_arg_ptr);
37561         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
37562         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
37563                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37564                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
37565         }
37566         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
37567         int64_t ret_ref = 0;
37568         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37569         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37571         ret_ref = (uintptr_t)ret_var.inner;
37572         if (ret_var.is_owned) {
37573                 ret_ref |= 1;
37574         }
37575         return ret_ref;
37576 }
37577
37578 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
37579         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
37580         *ret_ret = SocketDescriptor_clone(arg);
37581         return (int64_t)ret_ret;
37582 }
37583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37584         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
37585         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
37586         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
37587         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
37588         return ret_conv;
37589 }
37590
37591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37592         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
37593         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
37594         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
37595         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
37596         *ret_ret = SocketDescriptor_clone(orig_conv);
37597         return (int64_t)ret_ret;
37598 }
37599
37600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37601         if ((this_ptr & 1) != 0) return;
37602         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37603         CHECK_ACCESS(this_ptr_ptr);
37604         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
37605         FREE((void*)this_ptr);
37606         SocketDescriptor_free(this_ptr_conv);
37607 }
37608
37609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37610         LDKPeerHandleError this_obj_conv;
37611         this_obj_conv.inner = (void*)(this_obj & (~1));
37612         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37614         PeerHandleError_free(this_obj_conv);
37615 }
37616
37617 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
37618         LDKPeerHandleError this_ptr_conv;
37619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37620         this_ptr_conv.is_owned = false;
37621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37622         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
37623         return ret_conv;
37624 }
37625
37626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37627         LDKPeerHandleError this_ptr_conv;
37628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37629         this_ptr_conv.is_owned = false;
37630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37631         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
37632 }
37633
37634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
37635         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
37636         int64_t ret_ref = 0;
37637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37640         ret_ref = (uintptr_t)ret_var.inner;
37641         if (ret_var.is_owned) {
37642                 ret_ref |= 1;
37643         }
37644         return ret_ref;
37645 }
37646
37647 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
37648         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
37649 int64_t ret_ref = 0;
37650 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37651 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37652 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37653 ret_ref = (uintptr_t)ret_var.inner;
37654 if (ret_var.is_owned) {
37655         ret_ref |= 1;
37656 }
37657         return ret_ref;
37658 }
37659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37660         LDKPeerHandleError arg_conv;
37661         arg_conv.inner = (void*)(arg & (~1));
37662         arg_conv.is_owned = false;
37663         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37664         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
37665         return ret_conv;
37666 }
37667
37668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37669         LDKPeerHandleError orig_conv;
37670         orig_conv.inner = (void*)(orig & (~1));
37671         orig_conv.is_owned = false;
37672         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37673         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
37674         int64_t ret_ref = 0;
37675         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37676         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37678         ret_ref = (uintptr_t)ret_var.inner;
37679         if (ret_var.is_owned) {
37680                 ret_ref |= 1;
37681         }
37682         return ret_ref;
37683 }
37684
37685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37686         LDKPeerManager this_obj_conv;
37687         this_obj_conv.inner = (void*)(this_obj & (~1));
37688         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37690         PeerManager_free(this_obj_conv);
37691 }
37692
37693 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) {
37694         LDKMessageHandler message_handler_conv;
37695         message_handler_conv.inner = (void*)(message_handler & (~1));
37696         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
37697         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
37698         // WARNING: we need a move here but no clone is available for LDKMessageHandler
37699         LDKSecretKey our_node_secret_ref;
37700         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
37701         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
37702         unsigned char ephemeral_random_data_arr[32];
37703         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
37704         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
37705         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
37706         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
37707         CHECK_ACCESS(logger_ptr);
37708         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37709         if (logger_conv.free == LDKLogger_JCalls_free) {
37710                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37711                 LDKLogger_JCalls_cloned(&logger_conv);
37712         }
37713         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
37714         CHECK_ACCESS(custom_message_handler_ptr);
37715         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
37716         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
37717                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37718                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
37719         }
37720         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
37721         int64_t ret_ref = 0;
37722         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37723         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37725         ret_ref = (uintptr_t)ret_var.inner;
37726         if (ret_var.is_owned) {
37727                 ret_ref |= 1;
37728         }
37729         return ret_ref;
37730 }
37731
37732 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
37733         LDKPeerManager this_arg_conv;
37734         this_arg_conv.inner = (void*)(this_arg & (~1));
37735         this_arg_conv.is_owned = false;
37736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37737         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
37738         jobjectArray ret_arr = NULL;
37739         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
37740         ;
37741         for (size_t i = 0; i < ret_var.datalen; i++) {
37742                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
37743                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
37744                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
37745         }
37746         
37747         FREE(ret_var.data);
37748         return ret_arr;
37749 }
37750
37751 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) {
37752         LDKPeerManager this_arg_conv;
37753         this_arg_conv.inner = (void*)(this_arg & (~1));
37754         this_arg_conv.is_owned = false;
37755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37756         LDKPublicKey their_node_id_ref;
37757         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
37758         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
37759         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37760         CHECK_ACCESS(descriptor_ptr);
37761         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
37762         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
37763                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37764                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
37765         }
37766         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
37767         CHECK_ACCESS(remote_network_address_ptr);
37768         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
37769         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
37770         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
37771         return (int64_t)ret_conv;
37772 }
37773
37774 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) {
37775         LDKPeerManager this_arg_conv;
37776         this_arg_conv.inner = (void*)(this_arg & (~1));
37777         this_arg_conv.is_owned = false;
37778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37779         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37780         CHECK_ACCESS(descriptor_ptr);
37781         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
37782         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
37783                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37784                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
37785         }
37786         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
37787         CHECK_ACCESS(remote_network_address_ptr);
37788         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
37789         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
37790         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
37791         return (int64_t)ret_conv;
37792 }
37793
37794 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) {
37795         LDKPeerManager this_arg_conv;
37796         this_arg_conv.inner = (void*)(this_arg & (~1));
37797         this_arg_conv.is_owned = false;
37798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37799         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37800         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
37801         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
37802         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
37803         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
37804         return (int64_t)ret_conv;
37805 }
37806
37807 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) {
37808         LDKPeerManager this_arg_conv;
37809         this_arg_conv.inner = (void*)(this_arg & (~1));
37810         this_arg_conv.is_owned = false;
37811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37812         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
37813         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
37814         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
37815         LDKu8slice data_ref;
37816         data_ref.datalen = (*env)->GetArrayLength(env, data);
37817         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
37818         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
37819         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
37820         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
37821         return (int64_t)ret_conv;
37822 }
37823
37824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
37825         LDKPeerManager this_arg_conv;
37826         this_arg_conv.inner = (void*)(this_arg & (~1));
37827         this_arg_conv.is_owned = false;
37828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37829         PeerManager_process_events(&this_arg_conv);
37830 }
37831
37832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
37833         LDKPeerManager this_arg_conv;
37834         this_arg_conv.inner = (void*)(this_arg & (~1));
37835         this_arg_conv.is_owned = false;
37836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37837         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
37838         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
37839         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
37840         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
37841 }
37842
37843 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) {
37844         LDKPeerManager this_arg_conv;
37845         this_arg_conv.inner = (void*)(this_arg & (~1));
37846         this_arg_conv.is_owned = false;
37847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37848         LDKPublicKey node_id_ref;
37849         CHECK((*env)->GetArrayLength(env, node_id) == 33);
37850         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
37851         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
37852 }
37853
37854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
37855         LDKPeerManager this_arg_conv;
37856         this_arg_conv.inner = (void*)(this_arg & (~1));
37857         this_arg_conv.is_owned = false;
37858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37859         PeerManager_disconnect_all_peers(&this_arg_conv);
37860 }
37861
37862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
37863         LDKPeerManager this_arg_conv;
37864         this_arg_conv.inner = (void*)(this_arg & (~1));
37865         this_arg_conv.is_owned = false;
37866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37867         PeerManager_timer_tick_occurred(&this_arg_conv);
37868 }
37869
37870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
37871         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
37872         return ret_conv;
37873 }
37874
37875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
37876         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
37877         return ret_conv;
37878 }
37879
37880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
37881         unsigned char commitment_seed_arr[32];
37882         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
37883         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
37884         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
37885         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37886         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
37887         return ret_arr;
37888 }
37889
37890 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) {
37891         LDKCVec_u8Z to_holder_script_ref;
37892         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
37893         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
37894         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
37895         LDKCVec_u8Z to_counterparty_script_ref;
37896         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
37897         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
37898         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
37899         LDKOutPoint funding_outpoint_conv;
37900         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
37901         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
37902         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
37903         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
37904         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);
37905         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37906         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37907         Transaction_free(ret_var);
37908         return ret_arr;
37909 }
37910
37911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37912         LDKCounterpartyCommitmentSecrets this_obj_conv;
37913         this_obj_conv.inner = (void*)(this_obj & (~1));
37914         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37916         CounterpartyCommitmentSecrets_free(this_obj_conv);
37917 }
37918
37919 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
37920         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
37921 int64_t ret_ref = 0;
37922 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37923 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37924 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37925 ret_ref = (uintptr_t)ret_var.inner;
37926 if (ret_var.is_owned) {
37927         ret_ref |= 1;
37928 }
37929         return ret_ref;
37930 }
37931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37932         LDKCounterpartyCommitmentSecrets arg_conv;
37933         arg_conv.inner = (void*)(arg & (~1));
37934         arg_conv.is_owned = false;
37935         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37936         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
37937         return ret_conv;
37938 }
37939
37940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37941         LDKCounterpartyCommitmentSecrets orig_conv;
37942         orig_conv.inner = (void*)(orig & (~1));
37943         orig_conv.is_owned = false;
37944         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37945         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
37946         int64_t ret_ref = 0;
37947         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37948         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37950         ret_ref = (uintptr_t)ret_var.inner;
37951         if (ret_var.is_owned) {
37952                 ret_ref |= 1;
37953         }
37954         return ret_ref;
37955 }
37956
37957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
37958         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
37959         int64_t ret_ref = 0;
37960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37963         ret_ref = (uintptr_t)ret_var.inner;
37964         if (ret_var.is_owned) {
37965                 ret_ref |= 1;
37966         }
37967         return ret_ref;
37968 }
37969
37970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
37971         LDKCounterpartyCommitmentSecrets this_arg_conv;
37972         this_arg_conv.inner = (void*)(this_arg & (~1));
37973         this_arg_conv.is_owned = false;
37974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37975         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
37976         return ret_conv;
37977 }
37978
37979 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) {
37980         LDKCounterpartyCommitmentSecrets this_arg_conv;
37981         this_arg_conv.inner = (void*)(this_arg & (~1));
37982         this_arg_conv.is_owned = false;
37983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37984         LDKThirtyTwoBytes secret_ref;
37985         CHECK((*env)->GetArrayLength(env, secret) == 32);
37986         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
37987         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
37988         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
37989         return (int64_t)ret_conv;
37990 }
37991
37992 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
37993         LDKCounterpartyCommitmentSecrets this_arg_conv;
37994         this_arg_conv.inner = (void*)(this_arg & (~1));
37995         this_arg_conv.is_owned = false;
37996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37997         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37998         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
37999         return ret_arr;
38000 }
38001
38002 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
38003         LDKCounterpartyCommitmentSecrets obj_conv;
38004         obj_conv.inner = (void*)(obj & (~1));
38005         obj_conv.is_owned = false;
38006         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38007         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
38008         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38009         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38010         CVec_u8Z_free(ret_var);
38011         return ret_arr;
38012 }
38013
38014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38015         LDKu8slice ser_ref;
38016         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38017         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38018         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
38019         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
38020         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38021         return (int64_t)ret_conv;
38022 }
38023
38024 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) {
38025         LDKPublicKey per_commitment_point_ref;
38026         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38027         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38028         unsigned char base_secret_arr[32];
38029         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
38030         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
38031         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
38032         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38033         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
38034         return (int64_t)ret_conv;
38035 }
38036
38037 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) {
38038         LDKPublicKey per_commitment_point_ref;
38039         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38040         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38041         LDKPublicKey base_point_ref;
38042         CHECK((*env)->GetArrayLength(env, base_point) == 33);
38043         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
38044         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38045         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
38046         return (int64_t)ret_conv;
38047 }
38048
38049 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) {
38050         unsigned char per_commitment_secret_arr[32];
38051         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
38052         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
38053         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
38054         unsigned char countersignatory_revocation_base_secret_arr[32];
38055         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
38056         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
38057         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
38058         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
38059         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
38060         return (int64_t)ret_conv;
38061 }
38062
38063 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) {
38064         LDKPublicKey per_commitment_point_ref;
38065         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38066         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38067         LDKPublicKey countersignatory_revocation_base_point_ref;
38068         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
38069         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
38070         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
38071         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
38072         return (int64_t)ret_conv;
38073 }
38074
38075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38076         LDKTxCreationKeys this_obj_conv;
38077         this_obj_conv.inner = (void*)(this_obj & (~1));
38078         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38080         TxCreationKeys_free(this_obj_conv);
38081 }
38082
38083 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
38084         LDKTxCreationKeys this_ptr_conv;
38085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38086         this_ptr_conv.is_owned = false;
38087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38088         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38089         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
38090         return ret_arr;
38091 }
38092
38093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38094         LDKTxCreationKeys this_ptr_conv;
38095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38096         this_ptr_conv.is_owned = false;
38097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38098         LDKPublicKey val_ref;
38099         CHECK((*env)->GetArrayLength(env, val) == 33);
38100         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38101         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
38102 }
38103
38104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38105         LDKTxCreationKeys this_ptr_conv;
38106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38107         this_ptr_conv.is_owned = false;
38108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38109         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38110         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
38111         return ret_arr;
38112 }
38113
38114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38115         LDKTxCreationKeys this_ptr_conv;
38116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38117         this_ptr_conv.is_owned = false;
38118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38119         LDKPublicKey val_ref;
38120         CHECK((*env)->GetArrayLength(env, val) == 33);
38121         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38122         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
38123 }
38124
38125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38126         LDKTxCreationKeys this_ptr_conv;
38127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38128         this_ptr_conv.is_owned = false;
38129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38130         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38131         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
38132         return ret_arr;
38133 }
38134
38135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38136         LDKTxCreationKeys this_ptr_conv;
38137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38138         this_ptr_conv.is_owned = false;
38139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38140         LDKPublicKey val_ref;
38141         CHECK((*env)->GetArrayLength(env, val) == 33);
38142         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38143         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
38144 }
38145
38146 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38147         LDKTxCreationKeys this_ptr_conv;
38148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38149         this_ptr_conv.is_owned = false;
38150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38151         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38152         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
38153         return ret_arr;
38154 }
38155
38156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38157         LDKTxCreationKeys this_ptr_conv;
38158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38159         this_ptr_conv.is_owned = false;
38160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38161         LDKPublicKey val_ref;
38162         CHECK((*env)->GetArrayLength(env, val) == 33);
38163         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38164         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
38165 }
38166
38167 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
38168         LDKTxCreationKeys this_ptr_conv;
38169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38170         this_ptr_conv.is_owned = false;
38171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38172         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38173         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
38174         return ret_arr;
38175 }
38176
38177 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) {
38178         LDKTxCreationKeys this_ptr_conv;
38179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38180         this_ptr_conv.is_owned = false;
38181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38182         LDKPublicKey val_ref;
38183         CHECK((*env)->GetArrayLength(env, val) == 33);
38184         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38185         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
38186 }
38187
38188 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) {
38189         LDKPublicKey per_commitment_point_arg_ref;
38190         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
38191         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
38192         LDKPublicKey revocation_key_arg_ref;
38193         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
38194         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
38195         LDKPublicKey broadcaster_htlc_key_arg_ref;
38196         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
38197         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
38198         LDKPublicKey countersignatory_htlc_key_arg_ref;
38199         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
38200         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
38201         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
38202         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
38203         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
38204         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);
38205         int64_t ret_ref = 0;
38206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38209         ret_ref = (uintptr_t)ret_var.inner;
38210         if (ret_var.is_owned) {
38211                 ret_ref |= 1;
38212         }
38213         return ret_ref;
38214 }
38215
38216 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
38217         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
38218 int64_t ret_ref = 0;
38219 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38220 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38221 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38222 ret_ref = (uintptr_t)ret_var.inner;
38223 if (ret_var.is_owned) {
38224         ret_ref |= 1;
38225 }
38226         return ret_ref;
38227 }
38228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38229         LDKTxCreationKeys arg_conv;
38230         arg_conv.inner = (void*)(arg & (~1));
38231         arg_conv.is_owned = false;
38232         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38233         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
38234         return ret_conv;
38235 }
38236
38237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38238         LDKTxCreationKeys orig_conv;
38239         orig_conv.inner = (void*)(orig & (~1));
38240         orig_conv.is_owned = false;
38241         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38242         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
38243         int64_t ret_ref = 0;
38244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38247         ret_ref = (uintptr_t)ret_var.inner;
38248         if (ret_var.is_owned) {
38249                 ret_ref |= 1;
38250         }
38251         return ret_ref;
38252 }
38253
38254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
38255         LDKTxCreationKeys obj_conv;
38256         obj_conv.inner = (void*)(obj & (~1));
38257         obj_conv.is_owned = false;
38258         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38259         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
38260         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38261         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38262         CVec_u8Z_free(ret_var);
38263         return ret_arr;
38264 }
38265
38266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38267         LDKu8slice ser_ref;
38268         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38269         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38270         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
38271         *ret_conv = TxCreationKeys_read(ser_ref);
38272         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38273         return (int64_t)ret_conv;
38274 }
38275
38276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38277         LDKChannelPublicKeys this_obj_conv;
38278         this_obj_conv.inner = (void*)(this_obj & (~1));
38279         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38281         ChannelPublicKeys_free(this_obj_conv);
38282 }
38283
38284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
38285         LDKChannelPublicKeys this_ptr_conv;
38286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38287         this_ptr_conv.is_owned = false;
38288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38289         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38290         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
38291         return ret_arr;
38292 }
38293
38294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38295         LDKChannelPublicKeys this_ptr_conv;
38296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38297         this_ptr_conv.is_owned = false;
38298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38299         LDKPublicKey val_ref;
38300         CHECK((*env)->GetArrayLength(env, val) == 33);
38301         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38302         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
38303 }
38304
38305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
38306         LDKChannelPublicKeys this_ptr_conv;
38307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38308         this_ptr_conv.is_owned = false;
38309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38310         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38311         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
38312         return ret_arr;
38313 }
38314
38315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38316         LDKChannelPublicKeys this_ptr_conv;
38317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38318         this_ptr_conv.is_owned = false;
38319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38320         LDKPublicKey val_ref;
38321         CHECK((*env)->GetArrayLength(env, val) == 33);
38322         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38323         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
38324 }
38325
38326 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
38327         LDKChannelPublicKeys this_ptr_conv;
38328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38329         this_ptr_conv.is_owned = false;
38330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38331         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38332         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
38333         return ret_arr;
38334 }
38335
38336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38337         LDKChannelPublicKeys this_ptr_conv;
38338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38339         this_ptr_conv.is_owned = false;
38340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38341         LDKPublicKey val_ref;
38342         CHECK((*env)->GetArrayLength(env, val) == 33);
38343         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38344         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
38345 }
38346
38347 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
38348         LDKChannelPublicKeys this_ptr_conv;
38349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38350         this_ptr_conv.is_owned = false;
38351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38352         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38353         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
38354         return ret_arr;
38355 }
38356
38357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38358         LDKChannelPublicKeys this_ptr_conv;
38359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38360         this_ptr_conv.is_owned = false;
38361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38362         LDKPublicKey val_ref;
38363         CHECK((*env)->GetArrayLength(env, val) == 33);
38364         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38365         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
38366 }
38367
38368 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
38369         LDKChannelPublicKeys this_ptr_conv;
38370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38371         this_ptr_conv.is_owned = false;
38372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38373         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38374         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
38375         return ret_arr;
38376 }
38377
38378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38379         LDKChannelPublicKeys this_ptr_conv;
38380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38381         this_ptr_conv.is_owned = false;
38382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38383         LDKPublicKey val_ref;
38384         CHECK((*env)->GetArrayLength(env, val) == 33);
38385         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38386         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
38387 }
38388
38389 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) {
38390         LDKPublicKey funding_pubkey_arg_ref;
38391         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
38392         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
38393         LDKPublicKey revocation_basepoint_arg_ref;
38394         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
38395         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
38396         LDKPublicKey payment_point_arg_ref;
38397         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
38398         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
38399         LDKPublicKey delayed_payment_basepoint_arg_ref;
38400         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
38401         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
38402         LDKPublicKey htlc_basepoint_arg_ref;
38403         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
38404         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
38405         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);
38406         int64_t ret_ref = 0;
38407         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38408         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38410         ret_ref = (uintptr_t)ret_var.inner;
38411         if (ret_var.is_owned) {
38412                 ret_ref |= 1;
38413         }
38414         return ret_ref;
38415 }
38416
38417 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
38418         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
38419 int64_t ret_ref = 0;
38420 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38421 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38422 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38423 ret_ref = (uintptr_t)ret_var.inner;
38424 if (ret_var.is_owned) {
38425         ret_ref |= 1;
38426 }
38427         return ret_ref;
38428 }
38429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38430         LDKChannelPublicKeys arg_conv;
38431         arg_conv.inner = (void*)(arg & (~1));
38432         arg_conv.is_owned = false;
38433         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38434         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
38435         return ret_conv;
38436 }
38437
38438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38439         LDKChannelPublicKeys orig_conv;
38440         orig_conv.inner = (void*)(orig & (~1));
38441         orig_conv.is_owned = false;
38442         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38443         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
38444         int64_t ret_ref = 0;
38445         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38446         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38448         ret_ref = (uintptr_t)ret_var.inner;
38449         if (ret_var.is_owned) {
38450                 ret_ref |= 1;
38451         }
38452         return ret_ref;
38453 }
38454
38455 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
38456         LDKChannelPublicKeys obj_conv;
38457         obj_conv.inner = (void*)(obj & (~1));
38458         obj_conv.is_owned = false;
38459         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38460         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
38461         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38462         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38463         CVec_u8Z_free(ret_var);
38464         return ret_arr;
38465 }
38466
38467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38468         LDKu8slice ser_ref;
38469         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38470         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38471         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
38472         *ret_conv = ChannelPublicKeys_read(ser_ref);
38473         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38474         return (int64_t)ret_conv;
38475 }
38476
38477 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) {
38478         LDKPublicKey per_commitment_point_ref;
38479         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38480         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38481         LDKPublicKey broadcaster_delayed_payment_base_ref;
38482         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
38483         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
38484         LDKPublicKey broadcaster_htlc_base_ref;
38485         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
38486         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
38487         LDKPublicKey countersignatory_revocation_base_ref;
38488         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
38489         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
38490         LDKPublicKey countersignatory_htlc_base_ref;
38491         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
38492         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
38493         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
38494         *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);
38495         return (int64_t)ret_conv;
38496 }
38497
38498 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) {
38499         LDKPublicKey per_commitment_point_ref;
38500         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
38501         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
38502         LDKChannelPublicKeys broadcaster_keys_conv;
38503         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
38504         broadcaster_keys_conv.is_owned = false;
38505         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
38506         LDKChannelPublicKeys countersignatory_keys_conv;
38507         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
38508         countersignatory_keys_conv.is_owned = false;
38509         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
38510         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
38511         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
38512         return (int64_t)ret_conv;
38513 }
38514
38515 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) {
38516         LDKPublicKey revocation_key_ref;
38517         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
38518         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
38519         LDKPublicKey broadcaster_delayed_payment_key_ref;
38520         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
38521         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
38522         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
38523         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38524         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38525         CVec_u8Z_free(ret_var);
38526         return ret_arr;
38527 }
38528
38529 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38530         LDKHTLCOutputInCommitment this_obj_conv;
38531         this_obj_conv.inner = (void*)(this_obj & (~1));
38532         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38534         HTLCOutputInCommitment_free(this_obj_conv);
38535 }
38536
38537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
38538         LDKHTLCOutputInCommitment this_ptr_conv;
38539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38540         this_ptr_conv.is_owned = false;
38541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38542         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
38543         return ret_conv;
38544 }
38545
38546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38547         LDKHTLCOutputInCommitment this_ptr_conv;
38548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38549         this_ptr_conv.is_owned = false;
38550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38551         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
38552 }
38553
38554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38555         LDKHTLCOutputInCommitment this_ptr_conv;
38556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38557         this_ptr_conv.is_owned = false;
38558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38559         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
38560         return ret_conv;
38561 }
38562
38563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38564         LDKHTLCOutputInCommitment this_ptr_conv;
38565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38566         this_ptr_conv.is_owned = false;
38567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38568         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
38569 }
38570
38571 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
38572         LDKHTLCOutputInCommitment this_ptr_conv;
38573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38574         this_ptr_conv.is_owned = false;
38575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38576         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
38577         return ret_conv;
38578 }
38579
38580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38581         LDKHTLCOutputInCommitment this_ptr_conv;
38582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38583         this_ptr_conv.is_owned = false;
38584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38585         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
38586 }
38587
38588 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38589         LDKHTLCOutputInCommitment this_ptr_conv;
38590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38591         this_ptr_conv.is_owned = false;
38592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38593         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38594         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
38595         return ret_arr;
38596 }
38597
38598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38599         LDKHTLCOutputInCommitment this_ptr_conv;
38600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38601         this_ptr_conv.is_owned = false;
38602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38603         LDKThirtyTwoBytes val_ref;
38604         CHECK((*env)->GetArrayLength(env, val) == 32);
38605         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38606         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
38607 }
38608
38609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
38610         LDKHTLCOutputInCommitment this_ptr_conv;
38611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38612         this_ptr_conv.is_owned = false;
38613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38614         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
38615         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
38616         int64_t ret_ref = (uintptr_t)ret_copy;
38617         return ret_ref;
38618 }
38619
38620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38621         LDKHTLCOutputInCommitment this_ptr_conv;
38622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38623         this_ptr_conv.is_owned = false;
38624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38625         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38626         CHECK_ACCESS(val_ptr);
38627         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
38628         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
38629         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
38630 }
38631
38632 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) {
38633         LDKThirtyTwoBytes payment_hash_arg_ref;
38634         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
38635         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
38636         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
38637         CHECK_ACCESS(transaction_output_index_arg_ptr);
38638         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
38639         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
38640         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
38641         int64_t ret_ref = 0;
38642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38645         ret_ref = (uintptr_t)ret_var.inner;
38646         if (ret_var.is_owned) {
38647                 ret_ref |= 1;
38648         }
38649         return ret_ref;
38650 }
38651
38652 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
38653         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
38654 int64_t ret_ref = 0;
38655 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38656 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38657 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38658 ret_ref = (uintptr_t)ret_var.inner;
38659 if (ret_var.is_owned) {
38660         ret_ref |= 1;
38661 }
38662         return ret_ref;
38663 }
38664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38665         LDKHTLCOutputInCommitment arg_conv;
38666         arg_conv.inner = (void*)(arg & (~1));
38667         arg_conv.is_owned = false;
38668         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38669         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
38670         return ret_conv;
38671 }
38672
38673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38674         LDKHTLCOutputInCommitment orig_conv;
38675         orig_conv.inner = (void*)(orig & (~1));
38676         orig_conv.is_owned = false;
38677         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38678         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
38679         int64_t ret_ref = 0;
38680         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38681         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38683         ret_ref = (uintptr_t)ret_var.inner;
38684         if (ret_var.is_owned) {
38685                 ret_ref |= 1;
38686         }
38687         return ret_ref;
38688 }
38689
38690 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
38691         LDKHTLCOutputInCommitment obj_conv;
38692         obj_conv.inner = (void*)(obj & (~1));
38693         obj_conv.is_owned = false;
38694         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38695         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
38696         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38697         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38698         CVec_u8Z_free(ret_var);
38699         return ret_arr;
38700 }
38701
38702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38703         LDKu8slice ser_ref;
38704         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38705         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38706         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
38707         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
38708         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38709         return (int64_t)ret_conv;
38710 }
38711
38712 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) {
38713         LDKHTLCOutputInCommitment htlc_conv;
38714         htlc_conv.inner = (void*)(htlc & (~1));
38715         htlc_conv.is_owned = false;
38716         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
38717         LDKTxCreationKeys keys_conv;
38718         keys_conv.inner = (void*)(keys & (~1));
38719         keys_conv.is_owned = false;
38720         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
38721         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
38722         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38723         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38724         CVec_u8Z_free(ret_var);
38725         return ret_arr;
38726 }
38727
38728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
38729         LDKPublicKey broadcaster_ref;
38730         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
38731         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
38732         LDKPublicKey countersignatory_ref;
38733         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
38734         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
38735         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
38736         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38737         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38738         CVec_u8Z_free(ret_var);
38739         return ret_arr;
38740 }
38741
38742 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) {
38743         unsigned char commitment_txid_arr[32];
38744         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
38745         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
38746         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
38747         LDKHTLCOutputInCommitment htlc_conv;
38748         htlc_conv.inner = (void*)(htlc & (~1));
38749         htlc_conv.is_owned = false;
38750         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
38751         LDKPublicKey broadcaster_delayed_payment_key_ref;
38752         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
38753         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
38754         LDKPublicKey revocation_key_ref;
38755         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
38756         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
38757         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);
38758         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38759         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38760         Transaction_free(ret_var);
38761         return ret_arr;
38762 }
38763
38764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
38765         LDKPublicKey funding_pubkey_ref;
38766         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
38767         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
38768         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
38769         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38770         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38771         CVec_u8Z_free(ret_var);
38772         return ret_arr;
38773 }
38774
38775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38776         LDKChannelTransactionParameters this_obj_conv;
38777         this_obj_conv.inner = (void*)(this_obj & (~1));
38778         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38780         ChannelTransactionParameters_free(this_obj_conv);
38781 }
38782
38783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
38784         LDKChannelTransactionParameters this_ptr_conv;
38785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38786         this_ptr_conv.is_owned = false;
38787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38788         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
38789         int64_t ret_ref = 0;
38790         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38791         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38793         ret_ref = (uintptr_t)ret_var.inner;
38794         if (ret_var.is_owned) {
38795                 ret_ref |= 1;
38796         }
38797         return ret_ref;
38798 }
38799
38800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38801         LDKChannelTransactionParameters this_ptr_conv;
38802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38803         this_ptr_conv.is_owned = false;
38804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38805         LDKChannelPublicKeys val_conv;
38806         val_conv.inner = (void*)(val & (~1));
38807         val_conv.is_owned = (val & 1) || (val == 0);
38808         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38809         val_conv = ChannelPublicKeys_clone(&val_conv);
38810         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
38811 }
38812
38813 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
38814         LDKChannelTransactionParameters this_ptr_conv;
38815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38816         this_ptr_conv.is_owned = false;
38817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38818         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
38819         return ret_conv;
38820 }
38821
38822 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) {
38823         LDKChannelTransactionParameters 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         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
38828 }
38829
38830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
38831         LDKChannelTransactionParameters this_ptr_conv;
38832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38833         this_ptr_conv.is_owned = false;
38834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38835         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
38836         return ret_conv;
38837 }
38838
38839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38840         LDKChannelTransactionParameters this_ptr_conv;
38841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38842         this_ptr_conv.is_owned = false;
38843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38844         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
38845 }
38846
38847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
38848         LDKChannelTransactionParameters this_ptr_conv;
38849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38850         this_ptr_conv.is_owned = false;
38851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38852         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
38853         int64_t ret_ref = 0;
38854         if ((uintptr_t)ret_var.inner > 4096) {
38855                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38856                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38858                 ret_ref = (uintptr_t)ret_var.inner;
38859                 if (ret_var.is_owned) {
38860                         ret_ref |= 1;
38861                 }
38862         }
38863         return ret_ref;
38864 }
38865
38866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38867         LDKChannelTransactionParameters this_ptr_conv;
38868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38869         this_ptr_conv.is_owned = false;
38870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38871         LDKCounterpartyChannelTransactionParameters val_conv;
38872         val_conv.inner = (void*)(val & (~1));
38873         val_conv.is_owned = (val & 1) || (val == 0);
38874         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38875         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
38876         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
38877 }
38878
38879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
38880         LDKChannelTransactionParameters this_ptr_conv;
38881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38882         this_ptr_conv.is_owned = false;
38883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38884         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
38885         int64_t ret_ref = 0;
38886         if ((uintptr_t)ret_var.inner > 4096) {
38887                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38888                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38890                 ret_ref = (uintptr_t)ret_var.inner;
38891                 if (ret_var.is_owned) {
38892                         ret_ref |= 1;
38893                 }
38894         }
38895         return ret_ref;
38896 }
38897
38898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38899         LDKChannelTransactionParameters this_ptr_conv;
38900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38901         this_ptr_conv.is_owned = false;
38902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38903         LDKOutPoint val_conv;
38904         val_conv.inner = (void*)(val & (~1));
38905         val_conv.is_owned = (val & 1) || (val == 0);
38906         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38907         val_conv = OutPoint_clone(&val_conv);
38908         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
38909 }
38910
38911 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
38912         LDKChannelTransactionParameters this_ptr_conv;
38913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38914         this_ptr_conv.is_owned = false;
38915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38916         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
38917         return ret_conv;
38918 }
38919
38920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
38921         LDKChannelTransactionParameters this_ptr_conv;
38922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38923         this_ptr_conv.is_owned = false;
38924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38925         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
38926         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
38927 }
38928
38929 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) {
38930         LDKChannelPublicKeys holder_pubkeys_arg_conv;
38931         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
38932         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
38933         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
38934         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
38935         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
38936         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
38937         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
38938         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
38939         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
38940         LDKOutPoint funding_outpoint_arg_conv;
38941         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
38942         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
38943         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
38944         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
38945         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
38946         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);
38947         int64_t ret_ref = 0;
38948         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38949         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38951         ret_ref = (uintptr_t)ret_var.inner;
38952         if (ret_var.is_owned) {
38953                 ret_ref |= 1;
38954         }
38955         return ret_ref;
38956 }
38957
38958 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
38959         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
38960 int64_t ret_ref = 0;
38961 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38962 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38963 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38964 ret_ref = (uintptr_t)ret_var.inner;
38965 if (ret_var.is_owned) {
38966         ret_ref |= 1;
38967 }
38968         return ret_ref;
38969 }
38970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38971         LDKChannelTransactionParameters arg_conv;
38972         arg_conv.inner = (void*)(arg & (~1));
38973         arg_conv.is_owned = false;
38974         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38975         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
38976         return ret_conv;
38977 }
38978
38979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38980         LDKChannelTransactionParameters orig_conv;
38981         orig_conv.inner = (void*)(orig & (~1));
38982         orig_conv.is_owned = false;
38983         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38984         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
38985         int64_t ret_ref = 0;
38986         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38987         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38989         ret_ref = (uintptr_t)ret_var.inner;
38990         if (ret_var.is_owned) {
38991                 ret_ref |= 1;
38992         }
38993         return ret_ref;
38994 }
38995
38996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38997         LDKCounterpartyChannelTransactionParameters this_obj_conv;
38998         this_obj_conv.inner = (void*)(this_obj & (~1));
38999         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39001         CounterpartyChannelTransactionParameters_free(this_obj_conv);
39002 }
39003
39004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
39005         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39007         this_ptr_conv.is_owned = false;
39008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39009         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
39010         int64_t ret_ref = 0;
39011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39014         ret_ref = (uintptr_t)ret_var.inner;
39015         if (ret_var.is_owned) {
39016                 ret_ref |= 1;
39017         }
39018         return ret_ref;
39019 }
39020
39021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39022         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39024         this_ptr_conv.is_owned = false;
39025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39026         LDKChannelPublicKeys val_conv;
39027         val_conv.inner = (void*)(val & (~1));
39028         val_conv.is_owned = (val & 1) || (val == 0);
39029         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39030         val_conv = ChannelPublicKeys_clone(&val_conv);
39031         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
39032 }
39033
39034 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
39035         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39037         this_ptr_conv.is_owned = false;
39038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39039         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
39040         return ret_conv;
39041 }
39042
39043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
39044         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
39045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39046         this_ptr_conv.is_owned = false;
39047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39048         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
39049 }
39050
39051 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) {
39052         LDKChannelPublicKeys pubkeys_arg_conv;
39053         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
39054         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
39055         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
39056         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
39057         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
39058         int64_t ret_ref = 0;
39059         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39060         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39062         ret_ref = (uintptr_t)ret_var.inner;
39063         if (ret_var.is_owned) {
39064                 ret_ref |= 1;
39065         }
39066         return ret_ref;
39067 }
39068
39069 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
39070         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
39071 int64_t ret_ref = 0;
39072 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39073 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39074 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39075 ret_ref = (uintptr_t)ret_var.inner;
39076 if (ret_var.is_owned) {
39077         ret_ref |= 1;
39078 }
39079         return ret_ref;
39080 }
39081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39082         LDKCounterpartyChannelTransactionParameters arg_conv;
39083         arg_conv.inner = (void*)(arg & (~1));
39084         arg_conv.is_owned = false;
39085         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39086         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
39087         return ret_conv;
39088 }
39089
39090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39091         LDKCounterpartyChannelTransactionParameters orig_conv;
39092         orig_conv.inner = (void*)(orig & (~1));
39093         orig_conv.is_owned = false;
39094         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39095         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
39096         int64_t ret_ref = 0;
39097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39100         ret_ref = (uintptr_t)ret_var.inner;
39101         if (ret_var.is_owned) {
39102                 ret_ref |= 1;
39103         }
39104         return ret_ref;
39105 }
39106
39107 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
39108         LDKChannelTransactionParameters this_arg_conv;
39109         this_arg_conv.inner = (void*)(this_arg & (~1));
39110         this_arg_conv.is_owned = false;
39111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39112         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
39113         return ret_conv;
39114 }
39115
39116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39117         LDKChannelTransactionParameters this_arg_conv;
39118         this_arg_conv.inner = (void*)(this_arg & (~1));
39119         this_arg_conv.is_owned = false;
39120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39121         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
39122         int64_t ret_ref = 0;
39123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39126         ret_ref = (uintptr_t)ret_var.inner;
39127         if (ret_var.is_owned) {
39128                 ret_ref |= 1;
39129         }
39130         return ret_ref;
39131 }
39132
39133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
39134         LDKChannelTransactionParameters this_arg_conv;
39135         this_arg_conv.inner = (void*)(this_arg & (~1));
39136         this_arg_conv.is_owned = false;
39137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39138         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
39139         int64_t ret_ref = 0;
39140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39143         ret_ref = (uintptr_t)ret_var.inner;
39144         if (ret_var.is_owned) {
39145                 ret_ref |= 1;
39146         }
39147         return ret_ref;
39148 }
39149
39150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
39151         LDKCounterpartyChannelTransactionParameters obj_conv;
39152         obj_conv.inner = (void*)(obj & (~1));
39153         obj_conv.is_owned = false;
39154         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39155         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
39156         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39157         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39158         CVec_u8Z_free(ret_var);
39159         return ret_arr;
39160 }
39161
39162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39163         LDKu8slice ser_ref;
39164         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39165         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39166         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
39167         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
39168         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39169         return (int64_t)ret_conv;
39170 }
39171
39172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
39173         LDKChannelTransactionParameters obj_conv;
39174         obj_conv.inner = (void*)(obj & (~1));
39175         obj_conv.is_owned = false;
39176         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39177         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
39178         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39179         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39180         CVec_u8Z_free(ret_var);
39181         return ret_arr;
39182 }
39183
39184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39185         LDKu8slice ser_ref;
39186         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39187         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39188         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
39189         *ret_conv = ChannelTransactionParameters_read(ser_ref);
39190         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39191         return (int64_t)ret_conv;
39192 }
39193
39194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39195         LDKDirectedChannelTransactionParameters this_obj_conv;
39196         this_obj_conv.inner = (void*)(this_obj & (~1));
39197         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39199         DirectedChannelTransactionParameters_free(this_obj_conv);
39200 }
39201
39202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
39203         LDKDirectedChannelTransactionParameters this_arg_conv;
39204         this_arg_conv.inner = (void*)(this_arg & (~1));
39205         this_arg_conv.is_owned = false;
39206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39207         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
39208         int64_t ret_ref = 0;
39209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39212         ret_ref = (uintptr_t)ret_var.inner;
39213         if (ret_var.is_owned) {
39214                 ret_ref |= 1;
39215         }
39216         return ret_ref;
39217 }
39218
39219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
39220         LDKDirectedChannelTransactionParameters this_arg_conv;
39221         this_arg_conv.inner = (void*)(this_arg & (~1));
39222         this_arg_conv.is_owned = false;
39223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39224         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
39225         int64_t ret_ref = 0;
39226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39229         ret_ref = (uintptr_t)ret_var.inner;
39230         if (ret_var.is_owned) {
39231                 ret_ref |= 1;
39232         }
39233         return ret_ref;
39234 }
39235
39236 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
39237         LDKDirectedChannelTransactionParameters this_arg_conv;
39238         this_arg_conv.inner = (void*)(this_arg & (~1));
39239         this_arg_conv.is_owned = false;
39240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39241         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
39242         return ret_conv;
39243 }
39244
39245 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
39246         LDKDirectedChannelTransactionParameters this_arg_conv;
39247         this_arg_conv.inner = (void*)(this_arg & (~1));
39248         this_arg_conv.is_owned = false;
39249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39250         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
39251         return ret_conv;
39252 }
39253
39254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
39255         LDKDirectedChannelTransactionParameters this_arg_conv;
39256         this_arg_conv.inner = (void*)(this_arg & (~1));
39257         this_arg_conv.is_owned = false;
39258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39259         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
39260         int64_t ret_ref = 0;
39261         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39262         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39264         ret_ref = (uintptr_t)ret_var.inner;
39265         if (ret_var.is_owned) {
39266                 ret_ref |= 1;
39267         }
39268         return ret_ref;
39269 }
39270
39271 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
39272         LDKDirectedChannelTransactionParameters this_arg_conv;
39273         this_arg_conv.inner = (void*)(this_arg & (~1));
39274         this_arg_conv.is_owned = false;
39275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39276         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
39277         return ret_conv;
39278 }
39279
39280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39281         LDKHolderCommitmentTransaction this_obj_conv;
39282         this_obj_conv.inner = (void*)(this_obj & (~1));
39283         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39285         HolderCommitmentTransaction_free(this_obj_conv);
39286 }
39287
39288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
39289         LDKHolderCommitmentTransaction this_ptr_conv;
39290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39291         this_ptr_conv.is_owned = false;
39292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39293         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39294         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
39295         return ret_arr;
39296 }
39297
39298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39299         LDKHolderCommitmentTransaction this_ptr_conv;
39300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39301         this_ptr_conv.is_owned = false;
39302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39303         LDKSignature val_ref;
39304         CHECK((*env)->GetArrayLength(env, val) == 64);
39305         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
39306         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
39307 }
39308
39309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
39310         LDKHolderCommitmentTransaction this_ptr_conv;
39311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39312         this_ptr_conv.is_owned = false;
39313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39314         LDKCVec_SignatureZ val_constr;
39315         val_constr.datalen = (*env)->GetArrayLength(env, val);
39316         if (val_constr.datalen > 0)
39317                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
39318         else
39319                 val_constr.data = NULL;
39320         for (size_t i = 0; i < val_constr.datalen; i++) {
39321                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
39322                 LDKSignature val_conv_8_ref;
39323                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
39324                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
39325                 val_constr.data[i] = val_conv_8_ref;
39326         }
39327         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
39328 }
39329
39330 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
39331         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
39332 int64_t ret_ref = 0;
39333 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39334 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39335 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39336 ret_ref = (uintptr_t)ret_var.inner;
39337 if (ret_var.is_owned) {
39338         ret_ref |= 1;
39339 }
39340         return ret_ref;
39341 }
39342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39343         LDKHolderCommitmentTransaction arg_conv;
39344         arg_conv.inner = (void*)(arg & (~1));
39345         arg_conv.is_owned = false;
39346         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39347         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
39348         return ret_conv;
39349 }
39350
39351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39352         LDKHolderCommitmentTransaction orig_conv;
39353         orig_conv.inner = (void*)(orig & (~1));
39354         orig_conv.is_owned = false;
39355         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39356         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
39357         int64_t ret_ref = 0;
39358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39361         ret_ref = (uintptr_t)ret_var.inner;
39362         if (ret_var.is_owned) {
39363                 ret_ref |= 1;
39364         }
39365         return ret_ref;
39366 }
39367
39368 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
39369         LDKHolderCommitmentTransaction obj_conv;
39370         obj_conv.inner = (void*)(obj & (~1));
39371         obj_conv.is_owned = false;
39372         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39373         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
39374         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39375         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39376         CVec_u8Z_free(ret_var);
39377         return ret_arr;
39378 }
39379
39380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39381         LDKu8slice ser_ref;
39382         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39383         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39384         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
39385         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
39386         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39387         return (int64_t)ret_conv;
39388 }
39389
39390 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) {
39391         LDKCommitmentTransaction commitment_tx_conv;
39392         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
39393         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
39394         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
39395         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
39396         LDKSignature counterparty_sig_ref;
39397         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
39398         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
39399         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
39400         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
39401         if (counterparty_htlc_sigs_constr.datalen > 0)
39402                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
39403         else
39404                 counterparty_htlc_sigs_constr.data = NULL;
39405         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
39406                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
39407                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
39408                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
39409                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
39410                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
39411         }
39412         LDKPublicKey holder_funding_key_ref;
39413         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
39414         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
39415         LDKPublicKey counterparty_funding_key_ref;
39416         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
39417         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
39418         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
39419         int64_t ret_ref = 0;
39420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39423         ret_ref = (uintptr_t)ret_var.inner;
39424         if (ret_var.is_owned) {
39425                 ret_ref |= 1;
39426         }
39427         return ret_ref;
39428 }
39429
39430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39431         LDKBuiltCommitmentTransaction this_obj_conv;
39432         this_obj_conv.inner = (void*)(this_obj & (~1));
39433         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39435         BuiltCommitmentTransaction_free(this_obj_conv);
39436 }
39437
39438 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
39439         LDKBuiltCommitmentTransaction this_ptr_conv;
39440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39441         this_ptr_conv.is_owned = false;
39442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39443         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
39444         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39445         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39446         Transaction_free(ret_var);
39447         return ret_arr;
39448 }
39449
39450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39451         LDKBuiltCommitmentTransaction this_ptr_conv;
39452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39453         this_ptr_conv.is_owned = false;
39454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39455         LDKTransaction val_ref;
39456         val_ref.datalen = (*env)->GetArrayLength(env, val);
39457         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
39458         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
39459         val_ref.data_is_owned = true;
39460         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
39461 }
39462
39463 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
39464         LDKBuiltCommitmentTransaction this_ptr_conv;
39465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39466         this_ptr_conv.is_owned = false;
39467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39468         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39469         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
39470         return ret_arr;
39471 }
39472
39473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39474         LDKBuiltCommitmentTransaction this_ptr_conv;
39475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39476         this_ptr_conv.is_owned = false;
39477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39478         LDKThirtyTwoBytes val_ref;
39479         CHECK((*env)->GetArrayLength(env, val) == 32);
39480         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39481         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
39482 }
39483
39484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
39485         LDKTransaction transaction_arg_ref;
39486         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
39487         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
39488         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
39489         transaction_arg_ref.data_is_owned = true;
39490         LDKThirtyTwoBytes txid_arg_ref;
39491         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
39492         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
39493         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
39494         int64_t ret_ref = 0;
39495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39498         ret_ref = (uintptr_t)ret_var.inner;
39499         if (ret_var.is_owned) {
39500                 ret_ref |= 1;
39501         }
39502         return ret_ref;
39503 }
39504
39505 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
39506         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
39507 int64_t ret_ref = 0;
39508 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39509 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39510 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39511 ret_ref = (uintptr_t)ret_var.inner;
39512 if (ret_var.is_owned) {
39513         ret_ref |= 1;
39514 }
39515         return ret_ref;
39516 }
39517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39518         LDKBuiltCommitmentTransaction arg_conv;
39519         arg_conv.inner = (void*)(arg & (~1));
39520         arg_conv.is_owned = false;
39521         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39522         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
39523         return ret_conv;
39524 }
39525
39526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39527         LDKBuiltCommitmentTransaction orig_conv;
39528         orig_conv.inner = (void*)(orig & (~1));
39529         orig_conv.is_owned = false;
39530         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39531         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
39532         int64_t ret_ref = 0;
39533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39536         ret_ref = (uintptr_t)ret_var.inner;
39537         if (ret_var.is_owned) {
39538                 ret_ref |= 1;
39539         }
39540         return ret_ref;
39541 }
39542
39543 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
39544         LDKBuiltCommitmentTransaction obj_conv;
39545         obj_conv.inner = (void*)(obj & (~1));
39546         obj_conv.is_owned = false;
39547         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39548         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
39549         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39550         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39551         CVec_u8Z_free(ret_var);
39552         return ret_arr;
39553 }
39554
39555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39556         LDKu8slice ser_ref;
39557         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39558         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39559         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
39560         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
39561         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39562         return (int64_t)ret_conv;
39563 }
39564
39565 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) {
39566         LDKBuiltCommitmentTransaction this_arg_conv;
39567         this_arg_conv.inner = (void*)(this_arg & (~1));
39568         this_arg_conv.is_owned = false;
39569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39570         LDKu8slice funding_redeemscript_ref;
39571         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39572         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39573         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39574         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
39575         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39576         return ret_arr;
39577 }
39578
39579 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) {
39580         LDKBuiltCommitmentTransaction this_arg_conv;
39581         this_arg_conv.inner = (void*)(this_arg & (~1));
39582         this_arg_conv.is_owned = false;
39583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39584         unsigned char funding_key_arr[32];
39585         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
39586         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
39587         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
39588         LDKu8slice funding_redeemscript_ref;
39589         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39590         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39591         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39592         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
39593         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39594         return ret_arr;
39595 }
39596
39597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39598         LDKClosingTransaction this_obj_conv;
39599         this_obj_conv.inner = (void*)(this_obj & (~1));
39600         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39602         ClosingTransaction_free(this_obj_conv);
39603 }
39604
39605 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
39606         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
39607 int64_t ret_ref = 0;
39608 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39609 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39610 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39611 ret_ref = (uintptr_t)ret_var.inner;
39612 if (ret_var.is_owned) {
39613         ret_ref |= 1;
39614 }
39615         return ret_ref;
39616 }
39617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39618         LDKClosingTransaction arg_conv;
39619         arg_conv.inner = (void*)(arg & (~1));
39620         arg_conv.is_owned = false;
39621         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39622         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
39623         return ret_conv;
39624 }
39625
39626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39627         LDKClosingTransaction orig_conv;
39628         orig_conv.inner = (void*)(orig & (~1));
39629         orig_conv.is_owned = false;
39630         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39631         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
39632         int64_t ret_ref = 0;
39633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39636         ret_ref = (uintptr_t)ret_var.inner;
39637         if (ret_var.is_owned) {
39638                 ret_ref |= 1;
39639         }
39640         return ret_ref;
39641 }
39642
39643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
39644         LDKClosingTransaction o_conv;
39645         o_conv.inner = (void*)(o & (~1));
39646         o_conv.is_owned = false;
39647         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39648         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
39649         return ret_conv;
39650 }
39651
39652 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) {
39653         LDKCVec_u8Z to_holder_script_ref;
39654         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
39655         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
39656         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
39657         LDKCVec_u8Z to_counterparty_script_ref;
39658         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
39659         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
39660         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
39661         LDKOutPoint funding_outpoint_conv;
39662         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
39663         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
39664         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
39665         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
39666         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
39667         int64_t ret_ref = 0;
39668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39671         ret_ref = (uintptr_t)ret_var.inner;
39672         if (ret_var.is_owned) {
39673                 ret_ref |= 1;
39674         }
39675         return ret_ref;
39676 }
39677
39678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
39679         LDKClosingTransaction this_arg_conv;
39680         this_arg_conv.inner = (void*)(this_arg & (~1));
39681         this_arg_conv.is_owned = false;
39682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39683         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
39684         int64_t ret_ref = 0;
39685         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39686         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39688         ret_ref = (uintptr_t)ret_var.inner;
39689         if (ret_var.is_owned) {
39690                 ret_ref |= 1;
39691         }
39692         return ret_ref;
39693 }
39694
39695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
39696         LDKClosingTransaction this_arg_conv;
39697         this_arg_conv.inner = (void*)(this_arg & (~1));
39698         this_arg_conv.is_owned = false;
39699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39700         LDKOutPoint funding_outpoint_conv;
39701         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
39702         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
39703         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
39704         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
39705         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
39706         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
39707         return (int64_t)ret_conv;
39708 }
39709
39710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39711         LDKClosingTransaction this_arg_conv;
39712         this_arg_conv.inner = (void*)(this_arg & (~1));
39713         this_arg_conv.is_owned = false;
39714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39715         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
39716         return ret_conv;
39717 }
39718
39719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39720         LDKClosingTransaction this_arg_conv;
39721         this_arg_conv.inner = (void*)(this_arg & (~1));
39722         this_arg_conv.is_owned = false;
39723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39724         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
39725         return ret_conv;
39726 }
39727
39728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
39729         LDKClosingTransaction this_arg_conv;
39730         this_arg_conv.inner = (void*)(this_arg & (~1));
39731         this_arg_conv.is_owned = false;
39732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39733         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
39734         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39735         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39736         return ret_arr;
39737 }
39738
39739 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
39740         LDKClosingTransaction this_arg_conv;
39741         this_arg_conv.inner = (void*)(this_arg & (~1));
39742         this_arg_conv.is_owned = false;
39743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39744         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
39745         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39746         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39747         return ret_arr;
39748 }
39749
39750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39751         LDKTrustedClosingTransaction this_obj_conv;
39752         this_obj_conv.inner = (void*)(this_obj & (~1));
39753         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39755         TrustedClosingTransaction_free(this_obj_conv);
39756 }
39757
39758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
39759         LDKTrustedClosingTransaction this_arg_conv;
39760         this_arg_conv.inner = (void*)(this_arg & (~1));
39761         this_arg_conv.is_owned = false;
39762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39763         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
39764         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39765         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39766         Transaction_free(ret_var);
39767         return ret_arr;
39768 }
39769
39770 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) {
39771         LDKTrustedClosingTransaction this_arg_conv;
39772         this_arg_conv.inner = (void*)(this_arg & (~1));
39773         this_arg_conv.is_owned = false;
39774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39775         LDKu8slice funding_redeemscript_ref;
39776         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39777         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39778         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39779         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
39780         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39781         return ret_arr;
39782 }
39783
39784 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) {
39785         LDKTrustedClosingTransaction this_arg_conv;
39786         this_arg_conv.inner = (void*)(this_arg & (~1));
39787         this_arg_conv.is_owned = false;
39788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39789         unsigned char funding_key_arr[32];
39790         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
39791         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
39792         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
39793         LDKu8slice funding_redeemscript_ref;
39794         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
39795         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
39796         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
39797         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
39798         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
39799         return ret_arr;
39800 }
39801
39802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39803         LDKCommitmentTransaction this_obj_conv;
39804         this_obj_conv.inner = (void*)(this_obj & (~1));
39805         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39807         CommitmentTransaction_free(this_obj_conv);
39808 }
39809
39810 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
39811         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
39812 int64_t ret_ref = 0;
39813 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39814 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39815 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39816 ret_ref = (uintptr_t)ret_var.inner;
39817 if (ret_var.is_owned) {
39818         ret_ref |= 1;
39819 }
39820         return ret_ref;
39821 }
39822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39823         LDKCommitmentTransaction arg_conv;
39824         arg_conv.inner = (void*)(arg & (~1));
39825         arg_conv.is_owned = false;
39826         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39827         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
39828         return ret_conv;
39829 }
39830
39831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39832         LDKCommitmentTransaction orig_conv;
39833         orig_conv.inner = (void*)(orig & (~1));
39834         orig_conv.is_owned = false;
39835         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39836         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
39837         int64_t ret_ref = 0;
39838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39841         ret_ref = (uintptr_t)ret_var.inner;
39842         if (ret_var.is_owned) {
39843                 ret_ref |= 1;
39844         }
39845         return ret_ref;
39846 }
39847
39848 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
39849         LDKCommitmentTransaction obj_conv;
39850         obj_conv.inner = (void*)(obj & (~1));
39851         obj_conv.is_owned = false;
39852         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39853         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
39854         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39855         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39856         CVec_u8Z_free(ret_var);
39857         return ret_arr;
39858 }
39859
39860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39861         LDKu8slice ser_ref;
39862         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39863         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39864         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
39865         *ret_conv = CommitmentTransaction_read(ser_ref);
39866         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39867         return (int64_t)ret_conv;
39868 }
39869
39870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
39871         LDKCommitmentTransaction this_arg_conv;
39872         this_arg_conv.inner = (void*)(this_arg & (~1));
39873         this_arg_conv.is_owned = false;
39874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39875         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
39876         return ret_conv;
39877 }
39878
39879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39880         LDKCommitmentTransaction this_arg_conv;
39881         this_arg_conv.inner = (void*)(this_arg & (~1));
39882         this_arg_conv.is_owned = false;
39883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39884         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
39885         return ret_conv;
39886 }
39887
39888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
39889         LDKCommitmentTransaction this_arg_conv;
39890         this_arg_conv.inner = (void*)(this_arg & (~1));
39891         this_arg_conv.is_owned = false;
39892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39893         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
39894         return ret_conv;
39895 }
39896
39897 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
39898         LDKCommitmentTransaction this_arg_conv;
39899         this_arg_conv.inner = (void*)(this_arg & (~1));
39900         this_arg_conv.is_owned = false;
39901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39902         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
39903         return ret_conv;
39904 }
39905
39906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
39907         LDKCommitmentTransaction this_arg_conv;
39908         this_arg_conv.inner = (void*)(this_arg & (~1));
39909         this_arg_conv.is_owned = false;
39910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39911         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
39912         int64_t ret_ref = 0;
39913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39916         ret_ref = (uintptr_t)ret_var.inner;
39917         if (ret_var.is_owned) {
39918                 ret_ref |= 1;
39919         }
39920         return ret_ref;
39921 }
39922
39923 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) {
39924         LDKCommitmentTransaction this_arg_conv;
39925         this_arg_conv.inner = (void*)(this_arg & (~1));
39926         this_arg_conv.is_owned = false;
39927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39928         LDKDirectedChannelTransactionParameters channel_parameters_conv;
39929         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
39930         channel_parameters_conv.is_owned = false;
39931         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
39932         LDKChannelPublicKeys broadcaster_keys_conv;
39933         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
39934         broadcaster_keys_conv.is_owned = false;
39935         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
39936         LDKChannelPublicKeys countersignatory_keys_conv;
39937         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
39938         countersignatory_keys_conv.is_owned = false;
39939         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
39940         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
39941         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
39942         return (int64_t)ret_conv;
39943 }
39944
39945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39946         LDKTrustedCommitmentTransaction this_obj_conv;
39947         this_obj_conv.inner = (void*)(this_obj & (~1));
39948         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39950         TrustedCommitmentTransaction_free(this_obj_conv);
39951 }
39952
39953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
39954         LDKTrustedCommitmentTransaction this_arg_conv;
39955         this_arg_conv.inner = (void*)(this_arg & (~1));
39956         this_arg_conv.is_owned = false;
39957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39958         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
39960         return ret_arr;
39961 }
39962
39963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
39964         LDKTrustedCommitmentTransaction this_arg_conv;
39965         this_arg_conv.inner = (void*)(this_arg & (~1));
39966         this_arg_conv.is_owned = false;
39967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39968         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
39969         int64_t ret_ref = 0;
39970         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39971         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39973         ret_ref = (uintptr_t)ret_var.inner;
39974         if (ret_var.is_owned) {
39975                 ret_ref |= 1;
39976         }
39977         return ret_ref;
39978 }
39979
39980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
39981         LDKTrustedCommitmentTransaction this_arg_conv;
39982         this_arg_conv.inner = (void*)(this_arg & (~1));
39983         this_arg_conv.is_owned = false;
39984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39985         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
39986         int64_t ret_ref = 0;
39987         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39988         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39990         ret_ref = (uintptr_t)ret_var.inner;
39991         if (ret_var.is_owned) {
39992                 ret_ref |= 1;
39993         }
39994         return ret_ref;
39995 }
39996
39997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
39998         LDKTrustedCommitmentTransaction this_arg_conv;
39999         this_arg_conv.inner = (void*)(this_arg & (~1));
40000         this_arg_conv.is_owned = false;
40001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40002         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
40003         return ret_conv;
40004 }
40005
40006 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) {
40007         LDKTrustedCommitmentTransaction this_arg_conv;
40008         this_arg_conv.inner = (void*)(this_arg & (~1));
40009         this_arg_conv.is_owned = false;
40010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40011         unsigned char htlc_base_key_arr[32];
40012         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
40013         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
40014         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
40015         LDKDirectedChannelTransactionParameters channel_parameters_conv;
40016         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
40017         channel_parameters_conv.is_owned = false;
40018         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
40019         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
40020         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
40021         return (int64_t)ret_conv;
40022 }
40023
40024 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) {
40025         LDKPublicKey broadcaster_payment_basepoint_ref;
40026         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
40027         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
40028         LDKPublicKey countersignatory_payment_basepoint_ref;
40029         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
40030         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
40031         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
40032         return ret_conv;
40033 }
40034
40035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40036         LDKInitFeatures a_conv;
40037         a_conv.inner = (void*)(a & (~1));
40038         a_conv.is_owned = false;
40039         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40040         LDKInitFeatures b_conv;
40041         b_conv.inner = (void*)(b & (~1));
40042         b_conv.is_owned = false;
40043         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40044         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
40045         return ret_conv;
40046 }
40047
40048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40049         LDKNodeFeatures a_conv;
40050         a_conv.inner = (void*)(a & (~1));
40051         a_conv.is_owned = false;
40052         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40053         LDKNodeFeatures b_conv;
40054         b_conv.inner = (void*)(b & (~1));
40055         b_conv.is_owned = false;
40056         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40057         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
40058         return ret_conv;
40059 }
40060
40061 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40062         LDKChannelFeatures a_conv;
40063         a_conv.inner = (void*)(a & (~1));
40064         a_conv.is_owned = false;
40065         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40066         LDKChannelFeatures b_conv;
40067         b_conv.inner = (void*)(b & (~1));
40068         b_conv.is_owned = false;
40069         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40070         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
40071         return ret_conv;
40072 }
40073
40074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40075         LDKInvoiceFeatures a_conv;
40076         a_conv.inner = (void*)(a & (~1));
40077         a_conv.is_owned = false;
40078         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40079         LDKInvoiceFeatures b_conv;
40080         b_conv.inner = (void*)(b & (~1));
40081         b_conv.is_owned = false;
40082         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40083         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
40084         return ret_conv;
40085 }
40086
40087 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40088         LDKChannelTypeFeatures a_conv;
40089         a_conv.inner = (void*)(a & (~1));
40090         a_conv.is_owned = false;
40091         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40092         LDKChannelTypeFeatures b_conv;
40093         b_conv.inner = (void*)(b & (~1));
40094         b_conv.is_owned = false;
40095         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40096         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
40097         return ret_conv;
40098 }
40099
40100 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
40101         LDKInitFeatures ret_var = InitFeatures_clone(arg);
40102 int64_t ret_ref = 0;
40103 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40104 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40105 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40106 ret_ref = (uintptr_t)ret_var.inner;
40107 if (ret_var.is_owned) {
40108         ret_ref |= 1;
40109 }
40110         return ret_ref;
40111 }
40112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40113         LDKInitFeatures arg_conv;
40114         arg_conv.inner = (void*)(arg & (~1));
40115         arg_conv.is_owned = false;
40116         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40117         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
40118         return ret_conv;
40119 }
40120
40121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40122         LDKInitFeatures orig_conv;
40123         orig_conv.inner = (void*)(orig & (~1));
40124         orig_conv.is_owned = false;
40125         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40126         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
40127         int64_t ret_ref = 0;
40128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40131         ret_ref = (uintptr_t)ret_var.inner;
40132         if (ret_var.is_owned) {
40133                 ret_ref |= 1;
40134         }
40135         return ret_ref;
40136 }
40137
40138 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
40139         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
40140 int64_t ret_ref = 0;
40141 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40142 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40143 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40144 ret_ref = (uintptr_t)ret_var.inner;
40145 if (ret_var.is_owned) {
40146         ret_ref |= 1;
40147 }
40148         return ret_ref;
40149 }
40150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40151         LDKNodeFeatures arg_conv;
40152         arg_conv.inner = (void*)(arg & (~1));
40153         arg_conv.is_owned = false;
40154         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40155         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
40156         return ret_conv;
40157 }
40158
40159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40160         LDKNodeFeatures orig_conv;
40161         orig_conv.inner = (void*)(orig & (~1));
40162         orig_conv.is_owned = false;
40163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40164         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
40165         int64_t ret_ref = 0;
40166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40169         ret_ref = (uintptr_t)ret_var.inner;
40170         if (ret_var.is_owned) {
40171                 ret_ref |= 1;
40172         }
40173         return ret_ref;
40174 }
40175
40176 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
40177         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
40178 int64_t ret_ref = 0;
40179 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40180 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40181 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40182 ret_ref = (uintptr_t)ret_var.inner;
40183 if (ret_var.is_owned) {
40184         ret_ref |= 1;
40185 }
40186         return ret_ref;
40187 }
40188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40189         LDKChannelFeatures arg_conv;
40190         arg_conv.inner = (void*)(arg & (~1));
40191         arg_conv.is_owned = false;
40192         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40193         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
40194         return ret_conv;
40195 }
40196
40197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40198         LDKChannelFeatures orig_conv;
40199         orig_conv.inner = (void*)(orig & (~1));
40200         orig_conv.is_owned = false;
40201         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40202         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
40203         int64_t ret_ref = 0;
40204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40207         ret_ref = (uintptr_t)ret_var.inner;
40208         if (ret_var.is_owned) {
40209                 ret_ref |= 1;
40210         }
40211         return ret_ref;
40212 }
40213
40214 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
40215         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
40216 int64_t ret_ref = 0;
40217 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40218 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40219 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40220 ret_ref = (uintptr_t)ret_var.inner;
40221 if (ret_var.is_owned) {
40222         ret_ref |= 1;
40223 }
40224         return ret_ref;
40225 }
40226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40227         LDKInvoiceFeatures arg_conv;
40228         arg_conv.inner = (void*)(arg & (~1));
40229         arg_conv.is_owned = false;
40230         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40231         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
40232         return ret_conv;
40233 }
40234
40235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40236         LDKInvoiceFeatures orig_conv;
40237         orig_conv.inner = (void*)(orig & (~1));
40238         orig_conv.is_owned = false;
40239         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40240         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
40241         int64_t ret_ref = 0;
40242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40245         ret_ref = (uintptr_t)ret_var.inner;
40246         if (ret_var.is_owned) {
40247                 ret_ref |= 1;
40248         }
40249         return ret_ref;
40250 }
40251
40252 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
40253         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
40254 int64_t ret_ref = 0;
40255 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40256 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40257 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40258 ret_ref = (uintptr_t)ret_var.inner;
40259 if (ret_var.is_owned) {
40260         ret_ref |= 1;
40261 }
40262         return ret_ref;
40263 }
40264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40265         LDKChannelTypeFeatures arg_conv;
40266         arg_conv.inner = (void*)(arg & (~1));
40267         arg_conv.is_owned = false;
40268         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40269         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
40270         return ret_conv;
40271 }
40272
40273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40274         LDKChannelTypeFeatures orig_conv;
40275         orig_conv.inner = (void*)(orig & (~1));
40276         orig_conv.is_owned = false;
40277         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40278         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
40279         int64_t ret_ref = 0;
40280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40283         ret_ref = (uintptr_t)ret_var.inner;
40284         if (ret_var.is_owned) {
40285                 ret_ref |= 1;
40286         }
40287         return ret_ref;
40288 }
40289
40290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40291         LDKInitFeatures this_obj_conv;
40292         this_obj_conv.inner = (void*)(this_obj & (~1));
40293         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40295         InitFeatures_free(this_obj_conv);
40296 }
40297
40298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40299         LDKNodeFeatures this_obj_conv;
40300         this_obj_conv.inner = (void*)(this_obj & (~1));
40301         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40303         NodeFeatures_free(this_obj_conv);
40304 }
40305
40306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40307         LDKChannelFeatures this_obj_conv;
40308         this_obj_conv.inner = (void*)(this_obj & (~1));
40309         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40311         ChannelFeatures_free(this_obj_conv);
40312 }
40313
40314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40315         LDKInvoiceFeatures this_obj_conv;
40316         this_obj_conv.inner = (void*)(this_obj & (~1));
40317         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40319         InvoiceFeatures_free(this_obj_conv);
40320 }
40321
40322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40323         LDKChannelTypeFeatures this_obj_conv;
40324         this_obj_conv.inner = (void*)(this_obj & (~1));
40325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40327         ChannelTypeFeatures_free(this_obj_conv);
40328 }
40329
40330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
40331         LDKInitFeatures ret_var = InitFeatures_empty();
40332         int64_t ret_ref = 0;
40333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40336         ret_ref = (uintptr_t)ret_var.inner;
40337         if (ret_var.is_owned) {
40338                 ret_ref |= 1;
40339         }
40340         return ret_ref;
40341 }
40342
40343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
40344         LDKInitFeatures ret_var = InitFeatures_known();
40345         int64_t ret_ref = 0;
40346         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40347         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40349         ret_ref = (uintptr_t)ret_var.inner;
40350         if (ret_var.is_owned) {
40351                 ret_ref |= 1;
40352         }
40353         return ret_ref;
40354 }
40355
40356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40357         LDKInitFeatures this_arg_conv;
40358         this_arg_conv.inner = (void*)(this_arg & (~1));
40359         this_arg_conv.is_owned = false;
40360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40361         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
40362         return ret_conv;
40363 }
40364
40365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
40366         LDKNodeFeatures ret_var = NodeFeatures_empty();
40367         int64_t ret_ref = 0;
40368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40371         ret_ref = (uintptr_t)ret_var.inner;
40372         if (ret_var.is_owned) {
40373                 ret_ref |= 1;
40374         }
40375         return ret_ref;
40376 }
40377
40378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
40379         LDKNodeFeatures ret_var = NodeFeatures_known();
40380         int64_t ret_ref = 0;
40381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40384         ret_ref = (uintptr_t)ret_var.inner;
40385         if (ret_var.is_owned) {
40386                 ret_ref |= 1;
40387         }
40388         return ret_ref;
40389 }
40390
40391 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40392         LDKNodeFeatures this_arg_conv;
40393         this_arg_conv.inner = (void*)(this_arg & (~1));
40394         this_arg_conv.is_owned = false;
40395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40396         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
40397         return ret_conv;
40398 }
40399
40400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
40401         LDKChannelFeatures ret_var = ChannelFeatures_empty();
40402         int64_t ret_ref = 0;
40403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40406         ret_ref = (uintptr_t)ret_var.inner;
40407         if (ret_var.is_owned) {
40408                 ret_ref |= 1;
40409         }
40410         return ret_ref;
40411 }
40412
40413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
40414         LDKChannelFeatures ret_var = ChannelFeatures_known();
40415         int64_t ret_ref = 0;
40416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40419         ret_ref = (uintptr_t)ret_var.inner;
40420         if (ret_var.is_owned) {
40421                 ret_ref |= 1;
40422         }
40423         return ret_ref;
40424 }
40425
40426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40427         LDKChannelFeatures this_arg_conv;
40428         this_arg_conv.inner = (void*)(this_arg & (~1));
40429         this_arg_conv.is_owned = false;
40430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40431         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
40432         return ret_conv;
40433 }
40434
40435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
40436         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
40437         int64_t ret_ref = 0;
40438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40441         ret_ref = (uintptr_t)ret_var.inner;
40442         if (ret_var.is_owned) {
40443                 ret_ref |= 1;
40444         }
40445         return ret_ref;
40446 }
40447
40448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
40449         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
40450         int64_t ret_ref = 0;
40451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40454         ret_ref = (uintptr_t)ret_var.inner;
40455         if (ret_var.is_owned) {
40456                 ret_ref |= 1;
40457         }
40458         return ret_ref;
40459 }
40460
40461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40462         LDKInvoiceFeatures this_arg_conv;
40463         this_arg_conv.inner = (void*)(this_arg & (~1));
40464         this_arg_conv.is_owned = false;
40465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40466         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
40467         return ret_conv;
40468 }
40469
40470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
40471         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
40472         int64_t ret_ref = 0;
40473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40476         ret_ref = (uintptr_t)ret_var.inner;
40477         if (ret_var.is_owned) {
40478                 ret_ref |= 1;
40479         }
40480         return ret_ref;
40481 }
40482
40483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
40484         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
40485         int64_t ret_ref = 0;
40486         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40487         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40489         ret_ref = (uintptr_t)ret_var.inner;
40490         if (ret_var.is_owned) {
40491                 ret_ref |= 1;
40492         }
40493         return ret_ref;
40494 }
40495
40496 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
40497         LDKChannelTypeFeatures this_arg_conv;
40498         this_arg_conv.inner = (void*)(this_arg & (~1));
40499         this_arg_conv.is_owned = false;
40500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40501         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
40502         return ret_conv;
40503 }
40504
40505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40506         LDKInitFeatures obj_conv;
40507         obj_conv.inner = (void*)(obj & (~1));
40508         obj_conv.is_owned = false;
40509         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40510         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
40511         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40512         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40513         CVec_u8Z_free(ret_var);
40514         return ret_arr;
40515 }
40516
40517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40518         LDKu8slice ser_ref;
40519         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40520         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40521         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
40522         *ret_conv = InitFeatures_read(ser_ref);
40523         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40524         return (int64_t)ret_conv;
40525 }
40526
40527 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40528         LDKChannelFeatures obj_conv;
40529         obj_conv.inner = (void*)(obj & (~1));
40530         obj_conv.is_owned = false;
40531         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40532         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
40533         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40534         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40535         CVec_u8Z_free(ret_var);
40536         return ret_arr;
40537 }
40538
40539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40540         LDKu8slice ser_ref;
40541         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40542         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40543         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
40544         *ret_conv = ChannelFeatures_read(ser_ref);
40545         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40546         return (int64_t)ret_conv;
40547 }
40548
40549 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40550         LDKNodeFeatures obj_conv;
40551         obj_conv.inner = (void*)(obj & (~1));
40552         obj_conv.is_owned = false;
40553         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40554         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
40555         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40556         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40557         CVec_u8Z_free(ret_var);
40558         return ret_arr;
40559 }
40560
40561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40562         LDKu8slice ser_ref;
40563         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40564         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40565         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
40566         *ret_conv = NodeFeatures_read(ser_ref);
40567         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40568         return (int64_t)ret_conv;
40569 }
40570
40571 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40572         LDKInvoiceFeatures obj_conv;
40573         obj_conv.inner = (void*)(obj & (~1));
40574         obj_conv.is_owned = false;
40575         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40576         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
40577         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40578         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40579         CVec_u8Z_free(ret_var);
40580         return ret_arr;
40581 }
40582
40583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40584         LDKu8slice ser_ref;
40585         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40586         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40587         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
40588         *ret_conv = InvoiceFeatures_read(ser_ref);
40589         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40590         return (int64_t)ret_conv;
40591 }
40592
40593 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
40594         LDKChannelTypeFeatures obj_conv;
40595         obj_conv.inner = (void*)(obj & (~1));
40596         obj_conv.is_owned = false;
40597         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40598         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
40599         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40600         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40601         CVec_u8Z_free(ret_var);
40602         return ret_arr;
40603 }
40604
40605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40606         LDKu8slice ser_ref;
40607         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40608         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40609         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
40610         *ret_conv = ChannelTypeFeatures_read(ser_ref);
40611         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40612         return (int64_t)ret_conv;
40613 }
40614
40615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40616         LDKInitFeatures this_arg_conv;
40617         this_arg_conv.inner = (void*)(this_arg & (~1));
40618         this_arg_conv.is_owned = false;
40619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40620         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
40621 }
40622
40623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40624         LDKInitFeatures this_arg_conv;
40625         this_arg_conv.inner = (void*)(this_arg & (~1));
40626         this_arg_conv.is_owned = false;
40627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40628         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
40629 }
40630
40631 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40632         LDKInitFeatures this_arg_conv;
40633         this_arg_conv.inner = (void*)(this_arg & (~1));
40634         this_arg_conv.is_owned = false;
40635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40636         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
40637         return ret_conv;
40638 }
40639
40640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40641         LDKNodeFeatures this_arg_conv;
40642         this_arg_conv.inner = (void*)(this_arg & (~1));
40643         this_arg_conv.is_owned = false;
40644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40645         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
40646 }
40647
40648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40649         LDKNodeFeatures this_arg_conv;
40650         this_arg_conv.inner = (void*)(this_arg & (~1));
40651         this_arg_conv.is_owned = false;
40652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40653         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
40654 }
40655
40656 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40657         LDKNodeFeatures this_arg_conv;
40658         this_arg_conv.inner = (void*)(this_arg & (~1));
40659         this_arg_conv.is_owned = false;
40660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40661         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
40662         return ret_conv;
40663 }
40664
40665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40666         LDKInitFeatures this_arg_conv;
40667         this_arg_conv.inner = (void*)(this_arg & (~1));
40668         this_arg_conv.is_owned = false;
40669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40670         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
40671         return ret_conv;
40672 }
40673
40674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
40675         LDKNodeFeatures this_arg_conv;
40676         this_arg_conv.inner = (void*)(this_arg & (~1));
40677         this_arg_conv.is_owned = false;
40678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40679         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
40680         return ret_conv;
40681 }
40682
40683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40684         LDKInitFeatures this_arg_conv;
40685         this_arg_conv.inner = (void*)(this_arg & (~1));
40686         this_arg_conv.is_owned = false;
40687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40688         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
40689 }
40690
40691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40692         LDKInitFeatures this_arg_conv;
40693         this_arg_conv.inner = (void*)(this_arg & (~1));
40694         this_arg_conv.is_owned = false;
40695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40696         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
40697 }
40698
40699 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
40700         LDKInitFeatures this_arg_conv;
40701         this_arg_conv.inner = (void*)(this_arg & (~1));
40702         this_arg_conv.is_owned = false;
40703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40704         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
40705         return ret_conv;
40706 }
40707
40708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40709         LDKInitFeatures this_arg_conv;
40710         this_arg_conv.inner = (void*)(this_arg & (~1));
40711         this_arg_conv.is_owned = false;
40712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40713         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
40714 }
40715
40716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40717         LDKInitFeatures this_arg_conv;
40718         this_arg_conv.inner = (void*)(this_arg & (~1));
40719         this_arg_conv.is_owned = false;
40720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40721         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
40722 }
40723
40724 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40725         LDKInitFeatures this_arg_conv;
40726         this_arg_conv.inner = (void*)(this_arg & (~1));
40727         this_arg_conv.is_owned = false;
40728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40729         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
40730         return ret_conv;
40731 }
40732
40733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40734         LDKNodeFeatures this_arg_conv;
40735         this_arg_conv.inner = (void*)(this_arg & (~1));
40736         this_arg_conv.is_owned = false;
40737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40738         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
40739 }
40740
40741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40742         LDKNodeFeatures this_arg_conv;
40743         this_arg_conv.inner = (void*)(this_arg & (~1));
40744         this_arg_conv.is_owned = false;
40745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40746         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
40747 }
40748
40749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40750         LDKNodeFeatures this_arg_conv;
40751         this_arg_conv.inner = (void*)(this_arg & (~1));
40752         this_arg_conv.is_owned = false;
40753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40754         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
40755         return ret_conv;
40756 }
40757
40758 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40759         LDKInitFeatures this_arg_conv;
40760         this_arg_conv.inner = (void*)(this_arg & (~1));
40761         this_arg_conv.is_owned = false;
40762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40763         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
40764         return ret_conv;
40765 }
40766
40767 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40768         LDKNodeFeatures this_arg_conv;
40769         this_arg_conv.inner = (void*)(this_arg & (~1));
40770         this_arg_conv.is_owned = false;
40771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40772         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
40773         return ret_conv;
40774 }
40775
40776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40777         LDKInitFeatures this_arg_conv;
40778         this_arg_conv.inner = (void*)(this_arg & (~1));
40779         this_arg_conv.is_owned = false;
40780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40781         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
40782 }
40783
40784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40785         LDKInitFeatures this_arg_conv;
40786         this_arg_conv.inner = (void*)(this_arg & (~1));
40787         this_arg_conv.is_owned = false;
40788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40789         InitFeatures_set_gossip_queries_required(&this_arg_conv);
40790 }
40791
40792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40793         LDKInitFeatures this_arg_conv;
40794         this_arg_conv.inner = (void*)(this_arg & (~1));
40795         this_arg_conv.is_owned = false;
40796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40797         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
40798         return ret_conv;
40799 }
40800
40801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40802         LDKNodeFeatures this_arg_conv;
40803         this_arg_conv.inner = (void*)(this_arg & (~1));
40804         this_arg_conv.is_owned = false;
40805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40806         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
40807 }
40808
40809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40810         LDKNodeFeatures this_arg_conv;
40811         this_arg_conv.inner = (void*)(this_arg & (~1));
40812         this_arg_conv.is_owned = false;
40813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40814         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
40815 }
40816
40817 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40818         LDKNodeFeatures this_arg_conv;
40819         this_arg_conv.inner = (void*)(this_arg & (~1));
40820         this_arg_conv.is_owned = false;
40821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40822         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
40823         return ret_conv;
40824 }
40825
40826 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40827         LDKInitFeatures this_arg_conv;
40828         this_arg_conv.inner = (void*)(this_arg & (~1));
40829         this_arg_conv.is_owned = false;
40830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40831         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
40832         return ret_conv;
40833 }
40834
40835 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
40836         LDKNodeFeatures this_arg_conv;
40837         this_arg_conv.inner = (void*)(this_arg & (~1));
40838         this_arg_conv.is_owned = false;
40839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40840         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
40841         return ret_conv;
40842 }
40843
40844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40845         LDKInitFeatures this_arg_conv;
40846         this_arg_conv.inner = (void*)(this_arg & (~1));
40847         this_arg_conv.is_owned = false;
40848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40849         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
40850 }
40851
40852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40853         LDKInitFeatures this_arg_conv;
40854         this_arg_conv.inner = (void*)(this_arg & (~1));
40855         this_arg_conv.is_owned = false;
40856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40857         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
40858 }
40859
40860 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40861         LDKInitFeatures this_arg_conv;
40862         this_arg_conv.inner = (void*)(this_arg & (~1));
40863         this_arg_conv.is_owned = false;
40864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40865         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
40866         return ret_conv;
40867 }
40868
40869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40870         LDKNodeFeatures this_arg_conv;
40871         this_arg_conv.inner = (void*)(this_arg & (~1));
40872         this_arg_conv.is_owned = false;
40873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40874         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
40875 }
40876
40877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40878         LDKNodeFeatures this_arg_conv;
40879         this_arg_conv.inner = (void*)(this_arg & (~1));
40880         this_arg_conv.is_owned = false;
40881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40882         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
40883 }
40884
40885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40886         LDKNodeFeatures this_arg_conv;
40887         this_arg_conv.inner = (void*)(this_arg & (~1));
40888         this_arg_conv.is_owned = false;
40889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40890         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
40891         return ret_conv;
40892 }
40893
40894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40895         LDKInvoiceFeatures this_arg_conv;
40896         this_arg_conv.inner = (void*)(this_arg & (~1));
40897         this_arg_conv.is_owned = false;
40898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40899         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
40900 }
40901
40902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40903         LDKInvoiceFeatures this_arg_conv;
40904         this_arg_conv.inner = (void*)(this_arg & (~1));
40905         this_arg_conv.is_owned = false;
40906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40907         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
40908 }
40909
40910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40911         LDKInvoiceFeatures this_arg_conv;
40912         this_arg_conv.inner = (void*)(this_arg & (~1));
40913         this_arg_conv.is_owned = false;
40914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40915         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
40916         return ret_conv;
40917 }
40918
40919 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40920         LDKInitFeatures this_arg_conv;
40921         this_arg_conv.inner = (void*)(this_arg & (~1));
40922         this_arg_conv.is_owned = false;
40923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40924         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
40925         return ret_conv;
40926 }
40927
40928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40929         LDKNodeFeatures this_arg_conv;
40930         this_arg_conv.inner = (void*)(this_arg & (~1));
40931         this_arg_conv.is_owned = false;
40932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40933         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
40934         return ret_conv;
40935 }
40936
40937 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
40938         LDKInvoiceFeatures this_arg_conv;
40939         this_arg_conv.inner = (void*)(this_arg & (~1));
40940         this_arg_conv.is_owned = false;
40941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40942         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
40943         return ret_conv;
40944 }
40945
40946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40947         LDKInitFeatures this_arg_conv;
40948         this_arg_conv.inner = (void*)(this_arg & (~1));
40949         this_arg_conv.is_owned = false;
40950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40951         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
40952 }
40953
40954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40955         LDKInitFeatures this_arg_conv;
40956         this_arg_conv.inner = (void*)(this_arg & (~1));
40957         this_arg_conv.is_owned = false;
40958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40959         InitFeatures_set_static_remote_key_required(&this_arg_conv);
40960 }
40961
40962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40963         LDKInitFeatures this_arg_conv;
40964         this_arg_conv.inner = (void*)(this_arg & (~1));
40965         this_arg_conv.is_owned = false;
40966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40967         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
40968         return ret_conv;
40969 }
40970
40971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40972         LDKNodeFeatures this_arg_conv;
40973         this_arg_conv.inner = (void*)(this_arg & (~1));
40974         this_arg_conv.is_owned = false;
40975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40976         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
40977 }
40978
40979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
40980         LDKNodeFeatures this_arg_conv;
40981         this_arg_conv.inner = (void*)(this_arg & (~1));
40982         this_arg_conv.is_owned = false;
40983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40984         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
40985 }
40986
40987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
40988         LDKNodeFeatures this_arg_conv;
40989         this_arg_conv.inner = (void*)(this_arg & (~1));
40990         this_arg_conv.is_owned = false;
40991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40992         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
40993         return ret_conv;
40994 }
40995
40996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
40997         LDKChannelTypeFeatures this_arg_conv;
40998         this_arg_conv.inner = (void*)(this_arg & (~1));
40999         this_arg_conv.is_owned = false;
41000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41001         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
41002 }
41003
41004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41005         LDKChannelTypeFeatures this_arg_conv;
41006         this_arg_conv.inner = (void*)(this_arg & (~1));
41007         this_arg_conv.is_owned = false;
41008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41009         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
41010 }
41011
41012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41013         LDKChannelTypeFeatures this_arg_conv;
41014         this_arg_conv.inner = (void*)(this_arg & (~1));
41015         this_arg_conv.is_owned = false;
41016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41017         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
41018         return ret_conv;
41019 }
41020
41021 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41022         LDKInitFeatures this_arg_conv;
41023         this_arg_conv.inner = (void*)(this_arg & (~1));
41024         this_arg_conv.is_owned = false;
41025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41026         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
41027         return ret_conv;
41028 }
41029
41030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41031         LDKNodeFeatures this_arg_conv;
41032         this_arg_conv.inner = (void*)(this_arg & (~1));
41033         this_arg_conv.is_owned = false;
41034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41035         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
41036         return ret_conv;
41037 }
41038
41039 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
41040         LDKChannelTypeFeatures this_arg_conv;
41041         this_arg_conv.inner = (void*)(this_arg & (~1));
41042         this_arg_conv.is_owned = false;
41043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41044         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
41045         return ret_conv;
41046 }
41047
41048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41049         LDKInitFeatures this_arg_conv;
41050         this_arg_conv.inner = (void*)(this_arg & (~1));
41051         this_arg_conv.is_owned = false;
41052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41053         InitFeatures_set_payment_secret_optional(&this_arg_conv);
41054 }
41055
41056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41057         LDKInitFeatures this_arg_conv;
41058         this_arg_conv.inner = (void*)(this_arg & (~1));
41059         this_arg_conv.is_owned = false;
41060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41061         InitFeatures_set_payment_secret_required(&this_arg_conv);
41062 }
41063
41064 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41065         LDKInitFeatures this_arg_conv;
41066         this_arg_conv.inner = (void*)(this_arg & (~1));
41067         this_arg_conv.is_owned = false;
41068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41069         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
41070         return ret_conv;
41071 }
41072
41073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41074         LDKNodeFeatures this_arg_conv;
41075         this_arg_conv.inner = (void*)(this_arg & (~1));
41076         this_arg_conv.is_owned = false;
41077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41078         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
41079 }
41080
41081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41082         LDKNodeFeatures this_arg_conv;
41083         this_arg_conv.inner = (void*)(this_arg & (~1));
41084         this_arg_conv.is_owned = false;
41085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41086         NodeFeatures_set_payment_secret_required(&this_arg_conv);
41087 }
41088
41089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41090         LDKNodeFeatures this_arg_conv;
41091         this_arg_conv.inner = (void*)(this_arg & (~1));
41092         this_arg_conv.is_owned = false;
41093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41094         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
41095         return ret_conv;
41096 }
41097
41098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41099         LDKInvoiceFeatures this_arg_conv;
41100         this_arg_conv.inner = (void*)(this_arg & (~1));
41101         this_arg_conv.is_owned = false;
41102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41103         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
41104 }
41105
41106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41107         LDKInvoiceFeatures this_arg_conv;
41108         this_arg_conv.inner = (void*)(this_arg & (~1));
41109         this_arg_conv.is_owned = false;
41110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41111         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
41112 }
41113
41114 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41115         LDKInvoiceFeatures this_arg_conv;
41116         this_arg_conv.inner = (void*)(this_arg & (~1));
41117         this_arg_conv.is_owned = false;
41118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41119         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
41120         return ret_conv;
41121 }
41122
41123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41124         LDKInitFeatures this_arg_conv;
41125         this_arg_conv.inner = (void*)(this_arg & (~1));
41126         this_arg_conv.is_owned = false;
41127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41128         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
41129         return ret_conv;
41130 }
41131
41132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41133         LDKNodeFeatures this_arg_conv;
41134         this_arg_conv.inner = (void*)(this_arg & (~1));
41135         this_arg_conv.is_owned = false;
41136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41137         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
41138         return ret_conv;
41139 }
41140
41141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41142         LDKInvoiceFeatures this_arg_conv;
41143         this_arg_conv.inner = (void*)(this_arg & (~1));
41144         this_arg_conv.is_owned = false;
41145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41146         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
41147         return ret_conv;
41148 }
41149
41150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41151         LDKInitFeatures this_arg_conv;
41152         this_arg_conv.inner = (void*)(this_arg & (~1));
41153         this_arg_conv.is_owned = false;
41154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41155         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
41156 }
41157
41158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41159         LDKInitFeatures this_arg_conv;
41160         this_arg_conv.inner = (void*)(this_arg & (~1));
41161         this_arg_conv.is_owned = false;
41162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41163         InitFeatures_set_basic_mpp_required(&this_arg_conv);
41164 }
41165
41166 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41167         LDKInitFeatures this_arg_conv;
41168         this_arg_conv.inner = (void*)(this_arg & (~1));
41169         this_arg_conv.is_owned = false;
41170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41171         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
41172         return ret_conv;
41173 }
41174
41175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41176         LDKNodeFeatures this_arg_conv;
41177         this_arg_conv.inner = (void*)(this_arg & (~1));
41178         this_arg_conv.is_owned = false;
41179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41180         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
41181 }
41182
41183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41184         LDKNodeFeatures this_arg_conv;
41185         this_arg_conv.inner = (void*)(this_arg & (~1));
41186         this_arg_conv.is_owned = false;
41187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41188         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
41189 }
41190
41191 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41192         LDKNodeFeatures this_arg_conv;
41193         this_arg_conv.inner = (void*)(this_arg & (~1));
41194         this_arg_conv.is_owned = false;
41195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41196         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
41197         return ret_conv;
41198 }
41199
41200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(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         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
41206 }
41207
41208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41209         LDKInvoiceFeatures this_arg_conv;
41210         this_arg_conv.inner = (void*)(this_arg & (~1));
41211         this_arg_conv.is_owned = false;
41212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41213         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
41214 }
41215
41216 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41217         LDKInvoiceFeatures this_arg_conv;
41218         this_arg_conv.inner = (void*)(this_arg & (~1));
41219         this_arg_conv.is_owned = false;
41220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41221         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
41222         return ret_conv;
41223 }
41224
41225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41226         LDKInitFeatures this_arg_conv;
41227         this_arg_conv.inner = (void*)(this_arg & (~1));
41228         this_arg_conv.is_owned = false;
41229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41230         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
41231         return ret_conv;
41232 }
41233
41234 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41235         LDKNodeFeatures this_arg_conv;
41236         this_arg_conv.inner = (void*)(this_arg & (~1));
41237         this_arg_conv.is_owned = false;
41238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41239         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
41240         return ret_conv;
41241 }
41242
41243 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
41244         LDKInvoiceFeatures this_arg_conv;
41245         this_arg_conv.inner = (void*)(this_arg & (~1));
41246         this_arg_conv.is_owned = false;
41247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41248         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
41249         return ret_conv;
41250 }
41251
41252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41253         LDKInitFeatures this_arg_conv;
41254         this_arg_conv.inner = (void*)(this_arg & (~1));
41255         this_arg_conv.is_owned = false;
41256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41257         InitFeatures_set_wumbo_optional(&this_arg_conv);
41258 }
41259
41260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41261         LDKInitFeatures this_arg_conv;
41262         this_arg_conv.inner = (void*)(this_arg & (~1));
41263         this_arg_conv.is_owned = false;
41264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41265         InitFeatures_set_wumbo_required(&this_arg_conv);
41266 }
41267
41268 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
41269         LDKInitFeatures this_arg_conv;
41270         this_arg_conv.inner = (void*)(this_arg & (~1));
41271         this_arg_conv.is_owned = false;
41272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41273         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
41274         return ret_conv;
41275 }
41276
41277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41278         LDKNodeFeatures this_arg_conv;
41279         this_arg_conv.inner = (void*)(this_arg & (~1));
41280         this_arg_conv.is_owned = false;
41281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41282         NodeFeatures_set_wumbo_optional(&this_arg_conv);
41283 }
41284
41285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41286         LDKNodeFeatures this_arg_conv;
41287         this_arg_conv.inner = (void*)(this_arg & (~1));
41288         this_arg_conv.is_owned = false;
41289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41290         NodeFeatures_set_wumbo_required(&this_arg_conv);
41291 }
41292
41293 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
41294         LDKNodeFeatures this_arg_conv;
41295         this_arg_conv.inner = (void*)(this_arg & (~1));
41296         this_arg_conv.is_owned = false;
41297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41298         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
41299         return ret_conv;
41300 }
41301
41302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
41303         LDKInitFeatures this_arg_conv;
41304         this_arg_conv.inner = (void*)(this_arg & (~1));
41305         this_arg_conv.is_owned = false;
41306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41307         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
41308         return ret_conv;
41309 }
41310
41311 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
41312         LDKNodeFeatures this_arg_conv;
41313         this_arg_conv.inner = (void*)(this_arg & (~1));
41314         this_arg_conv.is_owned = false;
41315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41316         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
41317         return ret_conv;
41318 }
41319
41320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41321         LDKInitFeatures this_arg_conv;
41322         this_arg_conv.inner = (void*)(this_arg & (~1));
41323         this_arg_conv.is_owned = false;
41324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41325         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
41326 }
41327
41328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41329         LDKInitFeatures this_arg_conv;
41330         this_arg_conv.inner = (void*)(this_arg & (~1));
41331         this_arg_conv.is_owned = false;
41332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41333         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
41334 }
41335
41336 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
41337         LDKInitFeatures this_arg_conv;
41338         this_arg_conv.inner = (void*)(this_arg & (~1));
41339         this_arg_conv.is_owned = false;
41340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41341         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
41342         return ret_conv;
41343 }
41344
41345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41346         LDKNodeFeatures this_arg_conv;
41347         this_arg_conv.inner = (void*)(this_arg & (~1));
41348         this_arg_conv.is_owned = false;
41349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41350         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
41351 }
41352
41353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41354         LDKNodeFeatures this_arg_conv;
41355         this_arg_conv.inner = (void*)(this_arg & (~1));
41356         this_arg_conv.is_owned = false;
41357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41358         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
41359 }
41360
41361 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
41362         LDKNodeFeatures this_arg_conv;
41363         this_arg_conv.inner = (void*)(this_arg & (~1));
41364         this_arg_conv.is_owned = false;
41365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41366         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
41367         return ret_conv;
41368 }
41369
41370 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(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_requires_shutdown_anysegwit(&this_arg_conv);
41376         return ret_conv;
41377 }
41378
41379 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(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         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
41385         return ret_conv;
41386 }
41387
41388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41389         LDKInitFeatures this_arg_conv;
41390         this_arg_conv.inner = (void*)(this_arg & (~1));
41391         this_arg_conv.is_owned = false;
41392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41393         InitFeatures_set_channel_type_optional(&this_arg_conv);
41394 }
41395
41396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41397         LDKInitFeatures this_arg_conv;
41398         this_arg_conv.inner = (void*)(this_arg & (~1));
41399         this_arg_conv.is_owned = false;
41400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41401         InitFeatures_set_channel_type_required(&this_arg_conv);
41402 }
41403
41404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(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_supports_channel_type(&this_arg_conv);
41410         return ret_conv;
41411 }
41412
41413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(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         NodeFeatures_set_channel_type_optional(&this_arg_conv);
41419 }
41420
41421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41422         LDKNodeFeatures this_arg_conv;
41423         this_arg_conv.inner = (void*)(this_arg & (~1));
41424         this_arg_conv.is_owned = false;
41425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41426         NodeFeatures_set_channel_type_required(&this_arg_conv);
41427 }
41428
41429 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
41430         LDKNodeFeatures this_arg_conv;
41431         this_arg_conv.inner = (void*)(this_arg & (~1));
41432         this_arg_conv.is_owned = false;
41433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41434         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
41435         return ret_conv;
41436 }
41437
41438 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(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_requires_channel_type(&this_arg_conv);
41444         return ret_conv;
41445 }
41446
41447 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
41448         LDKNodeFeatures 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         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
41453         return ret_conv;
41454 }
41455
41456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41457         LDKInitFeatures this_arg_conv;
41458         this_arg_conv.inner = (void*)(this_arg & (~1));
41459         this_arg_conv.is_owned = false;
41460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41461         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
41462 }
41463
41464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41465         LDKInitFeatures this_arg_conv;
41466         this_arg_conv.inner = (void*)(this_arg & (~1));
41467         this_arg_conv.is_owned = false;
41468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41469         InitFeatures_set_scid_privacy_required(&this_arg_conv);
41470 }
41471
41472 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41473         LDKInitFeatures 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         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
41478         return ret_conv;
41479 }
41480
41481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41482         LDKNodeFeatures this_arg_conv;
41483         this_arg_conv.inner = (void*)(this_arg & (~1));
41484         this_arg_conv.is_owned = false;
41485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41486         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
41487 }
41488
41489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41490         LDKNodeFeatures this_arg_conv;
41491         this_arg_conv.inner = (void*)(this_arg & (~1));
41492         this_arg_conv.is_owned = false;
41493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41494         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
41495 }
41496
41497 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41498         LDKNodeFeatures 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 = NodeFeatures_supports_scid_privacy(&this_arg_conv);
41503         return ret_conv;
41504 }
41505
41506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41507         LDKChannelTypeFeatures 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         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
41512 }
41513
41514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41515         LDKChannelTypeFeatures this_arg_conv;
41516         this_arg_conv.inner = (void*)(this_arg & (~1));
41517         this_arg_conv.is_owned = false;
41518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41519         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
41520 }
41521
41522 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41523         LDKChannelTypeFeatures this_arg_conv;
41524         this_arg_conv.inner = (void*)(this_arg & (~1));
41525         this_arg_conv.is_owned = false;
41526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41527         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
41528         return ret_conv;
41529 }
41530
41531 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(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_requires_scid_privacy(&this_arg_conv);
41537         return ret_conv;
41538 }
41539
41540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(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         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
41546         return ret_conv;
41547 }
41548
41549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
41550         LDKChannelTypeFeatures this_arg_conv;
41551         this_arg_conv.inner = (void*)(this_arg & (~1));
41552         this_arg_conv.is_owned = false;
41553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41554         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
41555         return ret_conv;
41556 }
41557
41558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41559         LDKInitFeatures this_arg_conv;
41560         this_arg_conv.inner = (void*)(this_arg & (~1));
41561         this_arg_conv.is_owned = false;
41562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41563         InitFeatures_set_zero_conf_optional(&this_arg_conv);
41564 }
41565
41566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41567         LDKInitFeatures this_arg_conv;
41568         this_arg_conv.inner = (void*)(this_arg & (~1));
41569         this_arg_conv.is_owned = false;
41570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41571         InitFeatures_set_zero_conf_required(&this_arg_conv);
41572 }
41573
41574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41575         LDKInitFeatures 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 = InitFeatures_supports_zero_conf(&this_arg_conv);
41580         return ret_conv;
41581 }
41582
41583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41584         LDKNodeFeatures 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         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
41589 }
41590
41591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41592         LDKNodeFeatures 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         NodeFeatures_set_zero_conf_required(&this_arg_conv);
41597 }
41598
41599 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41600         LDKNodeFeatures 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 = NodeFeatures_supports_zero_conf(&this_arg_conv);
41605         return ret_conv;
41606 }
41607
41608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41609         LDKChannelTypeFeatures 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         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
41614 }
41615
41616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41617         LDKChannelTypeFeatures 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         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
41622 }
41623
41624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41625         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
41630         return ret_conv;
41631 }
41632
41633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41634         LDKInitFeatures 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         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
41639         return ret_conv;
41640 }
41641
41642 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41643         LDKNodeFeatures this_arg_conv;
41644         this_arg_conv.inner = (void*)(this_arg & (~1));
41645         this_arg_conv.is_owned = false;
41646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41647         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
41648         return ret_conv;
41649 }
41650
41651 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
41652         LDKChannelTypeFeatures this_arg_conv;
41653         this_arg_conv.inner = (void*)(this_arg & (~1));
41654         this_arg_conv.is_owned = false;
41655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41656         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
41657         return ret_conv;
41658 }
41659
41660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41661         LDKNodeFeatures this_arg_conv;
41662         this_arg_conv.inner = (void*)(this_arg & (~1));
41663         this_arg_conv.is_owned = false;
41664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41665         NodeFeatures_set_keysend_optional(&this_arg_conv);
41666 }
41667
41668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41669         LDKNodeFeatures this_arg_conv;
41670         this_arg_conv.inner = (void*)(this_arg & (~1));
41671         this_arg_conv.is_owned = false;
41672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41673         NodeFeatures_set_keysend_required(&this_arg_conv);
41674 }
41675
41676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
41677         LDKNodeFeatures 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 = NodeFeatures_supports_keysend(&this_arg_conv);
41682         return ret_conv;
41683 }
41684
41685 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
41686         LDKNodeFeatures 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         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
41691         return ret_conv;
41692 }
41693
41694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41695         LDKShutdownScript this_obj_conv;
41696         this_obj_conv.inner = (void*)(this_obj & (~1));
41697         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41699         ShutdownScript_free(this_obj_conv);
41700 }
41701
41702 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
41703         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
41704 int64_t ret_ref = 0;
41705 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41706 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41707 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41708 ret_ref = (uintptr_t)ret_var.inner;
41709 if (ret_var.is_owned) {
41710         ret_ref |= 1;
41711 }
41712         return ret_ref;
41713 }
41714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41715         LDKShutdownScript arg_conv;
41716         arg_conv.inner = (void*)(arg & (~1));
41717         arg_conv.is_owned = false;
41718         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41719         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
41720         return ret_conv;
41721 }
41722
41723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41724         LDKShutdownScript orig_conv;
41725         orig_conv.inner = (void*)(orig & (~1));
41726         orig_conv.is_owned = false;
41727         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41728         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
41729         int64_t ret_ref = 0;
41730         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41731         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41733         ret_ref = (uintptr_t)ret_var.inner;
41734         if (ret_var.is_owned) {
41735                 ret_ref |= 1;
41736         }
41737         return ret_ref;
41738 }
41739
41740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41741         LDKInvalidShutdownScript this_obj_conv;
41742         this_obj_conv.inner = (void*)(this_obj & (~1));
41743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41745         InvalidShutdownScript_free(this_obj_conv);
41746 }
41747
41748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
41749         LDKInvalidShutdownScript this_ptr_conv;
41750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41751         this_ptr_conv.is_owned = false;
41752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41753         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
41754         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41755         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41756         return ret_arr;
41757 }
41758
41759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41760         LDKInvalidShutdownScript this_ptr_conv;
41761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41762         this_ptr_conv.is_owned = false;
41763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41764         LDKCVec_u8Z val_ref;
41765         val_ref.datalen = (*env)->GetArrayLength(env, val);
41766         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
41767         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
41768         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
41769 }
41770
41771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
41772         LDKCVec_u8Z script_arg_ref;
41773         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
41774         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
41775         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
41776         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
41777         int64_t ret_ref = 0;
41778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41781         ret_ref = (uintptr_t)ret_var.inner;
41782         if (ret_var.is_owned) {
41783                 ret_ref |= 1;
41784         }
41785         return ret_ref;
41786 }
41787
41788 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
41789         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
41790 int64_t ret_ref = 0;
41791 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41792 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41793 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41794 ret_ref = (uintptr_t)ret_var.inner;
41795 if (ret_var.is_owned) {
41796         ret_ref |= 1;
41797 }
41798         return ret_ref;
41799 }
41800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41801         LDKInvalidShutdownScript arg_conv;
41802         arg_conv.inner = (void*)(arg & (~1));
41803         arg_conv.is_owned = false;
41804         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41805         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
41806         return ret_conv;
41807 }
41808
41809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41810         LDKInvalidShutdownScript orig_conv;
41811         orig_conv.inner = (void*)(orig & (~1));
41812         orig_conv.is_owned = false;
41813         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41814         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
41815         int64_t ret_ref = 0;
41816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41819         ret_ref = (uintptr_t)ret_var.inner;
41820         if (ret_var.is_owned) {
41821                 ret_ref |= 1;
41822         }
41823         return ret_ref;
41824 }
41825
41826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
41827         LDKShutdownScript obj_conv;
41828         obj_conv.inner = (void*)(obj & (~1));
41829         obj_conv.is_owned = false;
41830         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41831         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
41832         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41833         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41834         CVec_u8Z_free(ret_var);
41835         return ret_arr;
41836 }
41837
41838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41839         LDKu8slice ser_ref;
41840         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41841         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41842         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
41843         *ret_conv = ShutdownScript_read(ser_ref);
41844         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41845         return (int64_t)ret_conv;
41846 }
41847
41848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
41849         unsigned char pubkey_hash_arr[20];
41850         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
41851         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
41852         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
41853         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
41854         int64_t ret_ref = 0;
41855         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41856         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41858         ret_ref = (uintptr_t)ret_var.inner;
41859         if (ret_var.is_owned) {
41860                 ret_ref |= 1;
41861         }
41862         return ret_ref;
41863 }
41864
41865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
41866         unsigned char script_hash_arr[32];
41867         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
41868         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
41869         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
41870         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
41871         int64_t ret_ref = 0;
41872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41875         ret_ref = (uintptr_t)ret_var.inner;
41876         if (ret_var.is_owned) {
41877                 ret_ref |= 1;
41878         }
41879         return ret_ref;
41880 }
41881
41882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
41883         
41884         LDKu8slice program_ref;
41885         program_ref.datalen = (*env)->GetArrayLength(env, program);
41886         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
41887         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
41888         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
41889         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
41890         return (int64_t)ret_conv;
41891 }
41892
41893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
41894         LDKShutdownScript this_arg_conv;
41895         this_arg_conv.inner = (void*)(this_arg & (~1));
41896         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41898         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
41899         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
41900         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41901         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41902         CVec_u8Z_free(ret_var);
41903         return ret_arr;
41904 }
41905
41906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
41907         LDKShutdownScript this_arg_conv;
41908         this_arg_conv.inner = (void*)(this_arg & (~1));
41909         this_arg_conv.is_owned = false;
41910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41911         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
41913         return ret_arr;
41914 }
41915
41916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
41917         LDKShutdownScript this_arg_conv;
41918         this_arg_conv.inner = (void*)(this_arg & (~1));
41919         this_arg_conv.is_owned = false;
41920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41921         LDKInitFeatures features_conv;
41922         features_conv.inner = (void*)(features & (~1));
41923         features_conv.is_owned = false;
41924         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
41925         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
41926         return ret_conv;
41927 }
41928
41929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41930         if ((this_ptr & 1) != 0) return;
41931         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41932         CHECK_ACCESS(this_ptr_ptr);
41933         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
41934         FREE((void*)this_ptr);
41935         CustomMessageReader_free(this_ptr_conv);
41936 }
41937
41938 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
41939         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
41940         *ret_ret = Type_clone(arg);
41941         return (int64_t)ret_ret;
41942 }
41943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41944         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
41945         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
41946         LDKType* arg_conv = (LDKType*)arg_ptr;
41947         int64_t ret_conv = Type_clone_ptr(arg_conv);
41948         return ret_conv;
41949 }
41950
41951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41952         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
41953         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
41954         LDKType* orig_conv = (LDKType*)orig_ptr;
41955         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
41956         *ret_ret = Type_clone(orig_conv);
41957         return (int64_t)ret_ret;
41958 }
41959
41960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41961         if ((this_ptr & 1) != 0) return;
41962         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41963         CHECK_ACCESS(this_ptr_ptr);
41964         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
41965         FREE((void*)this_ptr);
41966         Type_free(this_ptr_conv);
41967 }
41968
41969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41970         LDKNodeId this_obj_conv;
41971         this_obj_conv.inner = (void*)(this_obj & (~1));
41972         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41974         NodeId_free(this_obj_conv);
41975 }
41976
41977 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
41978         LDKNodeId ret_var = NodeId_clone(arg);
41979 int64_t ret_ref = 0;
41980 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41981 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41982 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41983 ret_ref = (uintptr_t)ret_var.inner;
41984 if (ret_var.is_owned) {
41985         ret_ref |= 1;
41986 }
41987         return ret_ref;
41988 }
41989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41990         LDKNodeId arg_conv;
41991         arg_conv.inner = (void*)(arg & (~1));
41992         arg_conv.is_owned = false;
41993         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41994         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
41995         return ret_conv;
41996 }
41997
41998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41999         LDKNodeId orig_conv;
42000         orig_conv.inner = (void*)(orig & (~1));
42001         orig_conv.is_owned = false;
42002         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42003         LDKNodeId ret_var = NodeId_clone(&orig_conv);
42004         int64_t ret_ref = 0;
42005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42008         ret_ref = (uintptr_t)ret_var.inner;
42009         if (ret_var.is_owned) {
42010                 ret_ref |= 1;
42011         }
42012         return ret_ref;
42013 }
42014
42015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
42016         LDKPublicKey pubkey_ref;
42017         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
42018         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
42019         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
42020         int64_t ret_ref = 0;
42021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42024         ret_ref = (uintptr_t)ret_var.inner;
42025         if (ret_var.is_owned) {
42026                 ret_ref |= 1;
42027         }
42028         return ret_ref;
42029 }
42030
42031 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
42032         LDKNodeId this_arg_conv;
42033         this_arg_conv.inner = (void*)(this_arg & (~1));
42034         this_arg_conv.is_owned = false;
42035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42036         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
42037         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42038         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42039         return ret_arr;
42040 }
42041
42042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
42043         LDKNodeId o_conv;
42044         o_conv.inner = (void*)(o & (~1));
42045         o_conv.is_owned = false;
42046         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42047         int64_t ret_conv = NodeId_hash(&o_conv);
42048         return ret_conv;
42049 }
42050
42051 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
42052         LDKNodeId obj_conv;
42053         obj_conv.inner = (void*)(obj & (~1));
42054         obj_conv.is_owned = false;
42055         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42056         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
42057         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42058         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42059         CVec_u8Z_free(ret_var);
42060         return ret_arr;
42061 }
42062
42063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42064         LDKu8slice ser_ref;
42065         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42066         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42067         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
42068         *ret_conv = NodeId_read(ser_ref);
42069         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42070         return (int64_t)ret_conv;
42071 }
42072
42073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42074         LDKNetworkGraph this_obj_conv;
42075         this_obj_conv.inner = (void*)(this_obj & (~1));
42076         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42078         NetworkGraph_free(this_obj_conv);
42079 }
42080
42081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42082         LDKReadOnlyNetworkGraph this_obj_conv;
42083         this_obj_conv.inner = (void*)(this_obj & (~1));
42084         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42086         ReadOnlyNetworkGraph_free(this_obj_conv);
42087 }
42088
42089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42090         if ((this_ptr & 1) != 0) return;
42091         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42092         CHECK_ACCESS(this_ptr_ptr);
42093         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
42094         FREE((void*)this_ptr);
42095         NetworkUpdate_free(this_ptr_conv);
42096 }
42097
42098 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
42099         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42100         *ret_copy = NetworkUpdate_clone(arg);
42101 int64_t ret_ref = (uintptr_t)ret_copy;
42102         return ret_ref;
42103 }
42104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42105         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
42106         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
42107         return ret_conv;
42108 }
42109
42110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42111         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
42112         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42113         *ret_copy = NetworkUpdate_clone(orig_conv);
42114         int64_t ret_ref = (uintptr_t)ret_copy;
42115         return ret_ref;
42116 }
42117
42118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
42119         LDKChannelUpdate msg_conv;
42120         msg_conv.inner = (void*)(msg & (~1));
42121         msg_conv.is_owned = (msg & 1) || (msg == 0);
42122         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
42123         msg_conv = ChannelUpdate_clone(&msg_conv);
42124         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42125         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
42126         int64_t ret_ref = (uintptr_t)ret_copy;
42127         return ret_ref;
42128 }
42129
42130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
42131         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42132         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
42133         int64_t ret_ref = (uintptr_t)ret_copy;
42134         return ret_ref;
42135 }
42136
42137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
42138         LDKPublicKey node_id_ref;
42139         CHECK((*env)->GetArrayLength(env, node_id) == 33);
42140         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
42141         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
42142         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
42143         int64_t ret_ref = (uintptr_t)ret_copy;
42144         return ret_ref;
42145 }
42146
42147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
42148         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
42149         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
42150         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42151         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42152         CVec_u8Z_free(ret_var);
42153         return ret_arr;
42154 }
42155
42156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42157         LDKu8slice ser_ref;
42158         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42159         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42160         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
42161         *ret_conv = NetworkUpdate_read(ser_ref);
42162         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42163         return (int64_t)ret_conv;
42164 }
42165
42166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42167         LDKP2PGossipSync this_obj_conv;
42168         this_obj_conv.inner = (void*)(this_obj & (~1));
42169         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42171         P2PGossipSync_free(this_obj_conv);
42172 }
42173
42174 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) {
42175         LDKNetworkGraph network_graph_conv;
42176         network_graph_conv.inner = (void*)(network_graph & (~1));
42177         network_graph_conv.is_owned = false;
42178         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42179         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
42180         CHECK_ACCESS(chain_access_ptr);
42181         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
42182         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
42183         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
42184                 // Manually implement clone for Java trait instances
42185                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
42186                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42187                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
42188                 }
42189         }
42190         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42191         CHECK_ACCESS(logger_ptr);
42192         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42193         if (logger_conv.free == LDKLogger_JCalls_free) {
42194                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42195                 LDKLogger_JCalls_cloned(&logger_conv);
42196         }
42197         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
42198         int64_t ret_ref = 0;
42199         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42200         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42202         ret_ref = (uintptr_t)ret_var.inner;
42203         if (ret_var.is_owned) {
42204                 ret_ref |= 1;
42205         }
42206         return ret_ref;
42207 }
42208
42209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
42210         LDKP2PGossipSync this_arg_conv;
42211         this_arg_conv.inner = (void*)(this_arg & (~1));
42212         this_arg_conv.is_owned = false;
42213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42214         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
42215         CHECK_ACCESS(chain_access_ptr);
42216         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
42217         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
42218         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
42219                 // Manually implement clone for Java trait instances
42220                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
42221                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42222                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
42223                 }
42224         }
42225         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
42226 }
42227
42228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
42229         LDKNetworkGraph 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         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
42234         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
42235         return (int64_t)ret_ret;
42236 }
42237
42238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
42239         LDKP2PGossipSync this_arg_conv;
42240         this_arg_conv.inner = (void*)(this_arg & (~1));
42241         this_arg_conv.is_owned = false;
42242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42243         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
42244         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
42245         return (int64_t)ret_ret;
42246 }
42247
42248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
42249         LDKP2PGossipSync this_arg_conv;
42250         this_arg_conv.inner = (void*)(this_arg & (~1));
42251         this_arg_conv.is_owned = false;
42252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42253         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
42254         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
42255         return (int64_t)ret_ret;
42256 }
42257
42258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42259         LDKChannelUpdateInfo this_obj_conv;
42260         this_obj_conv.inner = (void*)(this_obj & (~1));
42261         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42263         ChannelUpdateInfo_free(this_obj_conv);
42264 }
42265
42266 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
42267         LDKChannelUpdateInfo this_ptr_conv;
42268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42269         this_ptr_conv.is_owned = false;
42270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42271         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
42272         return ret_conv;
42273 }
42274
42275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42276         LDKChannelUpdateInfo this_ptr_conv;
42277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42278         this_ptr_conv.is_owned = false;
42279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42280         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
42281 }
42282
42283 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
42284         LDKChannelUpdateInfo this_ptr_conv;
42285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42286         this_ptr_conv.is_owned = false;
42287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42288         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
42289         return ret_conv;
42290 }
42291
42292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
42293         LDKChannelUpdateInfo this_ptr_conv;
42294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42295         this_ptr_conv.is_owned = false;
42296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42297         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
42298 }
42299
42300 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
42301         LDKChannelUpdateInfo this_ptr_conv;
42302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42303         this_ptr_conv.is_owned = false;
42304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42305         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
42306         return ret_conv;
42307 }
42308
42309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
42310         LDKChannelUpdateInfo this_ptr_conv;
42311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42312         this_ptr_conv.is_owned = false;
42313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42314         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
42315 }
42316
42317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42318         LDKChannelUpdateInfo this_ptr_conv;
42319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42320         this_ptr_conv.is_owned = false;
42321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42322         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
42323         return ret_conv;
42324 }
42325
42326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42327         LDKChannelUpdateInfo this_ptr_conv;
42328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42329         this_ptr_conv.is_owned = false;
42330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42331         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
42332 }
42333
42334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42335         LDKChannelUpdateInfo this_ptr_conv;
42336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42337         this_ptr_conv.is_owned = false;
42338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42339         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42340         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
42341         int64_t ret_ref = (uintptr_t)ret_copy;
42342         return ret_ref;
42343 }
42344
42345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42346         LDKChannelUpdateInfo this_ptr_conv;
42347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42348         this_ptr_conv.is_owned = false;
42349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42350         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42351         CHECK_ACCESS(val_ptr);
42352         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42353         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42354         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
42355 }
42356
42357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
42358         LDKChannelUpdateInfo this_ptr_conv;
42359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42360         this_ptr_conv.is_owned = false;
42361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42362         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
42363         int64_t ret_ref = 0;
42364         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42365         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42367         ret_ref = (uintptr_t)ret_var.inner;
42368         if (ret_var.is_owned) {
42369                 ret_ref |= 1;
42370         }
42371         return ret_ref;
42372 }
42373
42374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42375         LDKChannelUpdateInfo this_ptr_conv;
42376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42377         this_ptr_conv.is_owned = false;
42378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42379         LDKRoutingFees val_conv;
42380         val_conv.inner = (void*)(val & (~1));
42381         val_conv.is_owned = (val & 1) || (val == 0);
42382         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42383         val_conv = RoutingFees_clone(&val_conv);
42384         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
42385 }
42386
42387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
42388         LDKChannelUpdateInfo this_ptr_conv;
42389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42390         this_ptr_conv.is_owned = false;
42391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42392         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
42393         int64_t ret_ref = 0;
42394         if ((uintptr_t)ret_var.inner > 4096) {
42395                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42396                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42398                 ret_ref = (uintptr_t)ret_var.inner;
42399                 if (ret_var.is_owned) {
42400                         ret_ref |= 1;
42401                 }
42402         }
42403         return ret_ref;
42404 }
42405
42406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42407         LDKChannelUpdateInfo this_ptr_conv;
42408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42409         this_ptr_conv.is_owned = false;
42410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42411         LDKChannelUpdate val_conv;
42412         val_conv.inner = (void*)(val & (~1));
42413         val_conv.is_owned = (val & 1) || (val == 0);
42414         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42415         val_conv = ChannelUpdate_clone(&val_conv);
42416         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
42417 }
42418
42419 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) {
42420         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
42421         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42422         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42423         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
42424         LDKRoutingFees fees_arg_conv;
42425         fees_arg_conv.inner = (void*)(fees_arg & (~1));
42426         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
42427         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42428         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42429         LDKChannelUpdate last_update_message_arg_conv;
42430         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
42431         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
42432         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
42433         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
42434         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
42435         int64_t ret_ref = 0;
42436         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42437         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42439         ret_ref = (uintptr_t)ret_var.inner;
42440         if (ret_var.is_owned) {
42441                 ret_ref |= 1;
42442         }
42443         return ret_ref;
42444 }
42445
42446 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
42447         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
42448 int64_t ret_ref = 0;
42449 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42450 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42451 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42452 ret_ref = (uintptr_t)ret_var.inner;
42453 if (ret_var.is_owned) {
42454         ret_ref |= 1;
42455 }
42456         return ret_ref;
42457 }
42458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42459         LDKChannelUpdateInfo arg_conv;
42460         arg_conv.inner = (void*)(arg & (~1));
42461         arg_conv.is_owned = false;
42462         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42463         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
42464         return ret_conv;
42465 }
42466
42467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42468         LDKChannelUpdateInfo orig_conv;
42469         orig_conv.inner = (void*)(orig & (~1));
42470         orig_conv.is_owned = false;
42471         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42472         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
42473         int64_t ret_ref = 0;
42474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42477         ret_ref = (uintptr_t)ret_var.inner;
42478         if (ret_var.is_owned) {
42479                 ret_ref |= 1;
42480         }
42481         return ret_ref;
42482 }
42483
42484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
42485         LDKChannelUpdateInfo obj_conv;
42486         obj_conv.inner = (void*)(obj & (~1));
42487         obj_conv.is_owned = false;
42488         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42489         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
42490         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42491         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42492         CVec_u8Z_free(ret_var);
42493         return ret_arr;
42494 }
42495
42496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42497         LDKu8slice ser_ref;
42498         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42499         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42500         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
42501         *ret_conv = ChannelUpdateInfo_read(ser_ref);
42502         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42503         return (int64_t)ret_conv;
42504 }
42505
42506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42507         LDKChannelInfo this_obj_conv;
42508         this_obj_conv.inner = (void*)(this_obj & (~1));
42509         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42511         ChannelInfo_free(this_obj_conv);
42512 }
42513
42514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
42515         LDKChannelInfo this_ptr_conv;
42516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42517         this_ptr_conv.is_owned = false;
42518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42519         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
42520         int64_t ret_ref = 0;
42521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42524         ret_ref = (uintptr_t)ret_var.inner;
42525         if (ret_var.is_owned) {
42526                 ret_ref |= 1;
42527         }
42528         return ret_ref;
42529 }
42530
42531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42532         LDKChannelInfo this_ptr_conv;
42533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42534         this_ptr_conv.is_owned = false;
42535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42536         LDKChannelFeatures val_conv;
42537         val_conv.inner = (void*)(val & (~1));
42538         val_conv.is_owned = (val & 1) || (val == 0);
42539         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42540         val_conv = ChannelFeatures_clone(&val_conv);
42541         ChannelInfo_set_features(&this_ptr_conv, val_conv);
42542 }
42543
42544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
42545         LDKChannelInfo this_ptr_conv;
42546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42547         this_ptr_conv.is_owned = false;
42548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42549         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
42550         int64_t ret_ref = 0;
42551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42554         ret_ref = (uintptr_t)ret_var.inner;
42555         if (ret_var.is_owned) {
42556                 ret_ref |= 1;
42557         }
42558         return ret_ref;
42559 }
42560
42561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42562         LDKChannelInfo this_ptr_conv;
42563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42564         this_ptr_conv.is_owned = false;
42565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42566         LDKNodeId val_conv;
42567         val_conv.inner = (void*)(val & (~1));
42568         val_conv.is_owned = (val & 1) || (val == 0);
42569         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42570         val_conv = NodeId_clone(&val_conv);
42571         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
42572 }
42573
42574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
42575         LDKChannelInfo this_ptr_conv;
42576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42577         this_ptr_conv.is_owned = false;
42578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42579         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
42580         int64_t ret_ref = 0;
42581         if ((uintptr_t)ret_var.inner > 4096) {
42582                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42583                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42585                 ret_ref = (uintptr_t)ret_var.inner;
42586                 if (ret_var.is_owned) {
42587                         ret_ref |= 1;
42588                 }
42589         }
42590         return ret_ref;
42591 }
42592
42593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42594         LDKChannelInfo this_ptr_conv;
42595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42596         this_ptr_conv.is_owned = false;
42597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42598         LDKChannelUpdateInfo val_conv;
42599         val_conv.inner = (void*)(val & (~1));
42600         val_conv.is_owned = (val & 1) || (val == 0);
42601         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42602         val_conv = ChannelUpdateInfo_clone(&val_conv);
42603         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
42604 }
42605
42606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
42607         LDKChannelInfo this_ptr_conv;
42608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42609         this_ptr_conv.is_owned = false;
42610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42611         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
42612         int64_t ret_ref = 0;
42613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42616         ret_ref = (uintptr_t)ret_var.inner;
42617         if (ret_var.is_owned) {
42618                 ret_ref |= 1;
42619         }
42620         return ret_ref;
42621 }
42622
42623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42624         LDKChannelInfo this_ptr_conv;
42625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42626         this_ptr_conv.is_owned = false;
42627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42628         LDKNodeId val_conv;
42629         val_conv.inner = (void*)(val & (~1));
42630         val_conv.is_owned = (val & 1) || (val == 0);
42631         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42632         val_conv = NodeId_clone(&val_conv);
42633         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
42634 }
42635
42636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
42637         LDKChannelInfo this_ptr_conv;
42638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42639         this_ptr_conv.is_owned = false;
42640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42641         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
42642         int64_t ret_ref = 0;
42643         if ((uintptr_t)ret_var.inner > 4096) {
42644                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42645                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42647                 ret_ref = (uintptr_t)ret_var.inner;
42648                 if (ret_var.is_owned) {
42649                         ret_ref |= 1;
42650                 }
42651         }
42652         return ret_ref;
42653 }
42654
42655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42656         LDKChannelInfo this_ptr_conv;
42657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42658         this_ptr_conv.is_owned = false;
42659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42660         LDKChannelUpdateInfo val_conv;
42661         val_conv.inner = (void*)(val & (~1));
42662         val_conv.is_owned = (val & 1) || (val == 0);
42663         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42664         val_conv = ChannelUpdateInfo_clone(&val_conv);
42665         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
42666 }
42667
42668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
42669         LDKChannelInfo this_ptr_conv;
42670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42671         this_ptr_conv.is_owned = false;
42672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42673         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42674         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
42675         int64_t ret_ref = (uintptr_t)ret_copy;
42676         return ret_ref;
42677 }
42678
42679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42680         LDKChannelInfo this_ptr_conv;
42681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42682         this_ptr_conv.is_owned = false;
42683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42684         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42685         CHECK_ACCESS(val_ptr);
42686         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42687         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42688         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
42689 }
42690
42691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
42692         LDKChannelInfo this_ptr_conv;
42693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42694         this_ptr_conv.is_owned = false;
42695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42696         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
42697         int64_t ret_ref = 0;
42698         if ((uintptr_t)ret_var.inner > 4096) {
42699                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42700                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42702                 ret_ref = (uintptr_t)ret_var.inner;
42703                 if (ret_var.is_owned) {
42704                         ret_ref |= 1;
42705                 }
42706         }
42707         return ret_ref;
42708 }
42709
42710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42711         LDKChannelInfo this_ptr_conv;
42712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42713         this_ptr_conv.is_owned = false;
42714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42715         LDKChannelAnnouncement val_conv;
42716         val_conv.inner = (void*)(val & (~1));
42717         val_conv.is_owned = (val & 1) || (val == 0);
42718         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42719         val_conv = ChannelAnnouncement_clone(&val_conv);
42720         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
42721 }
42722
42723 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
42724         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
42725 int64_t ret_ref = 0;
42726 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42727 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42728 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42729 ret_ref = (uintptr_t)ret_var.inner;
42730 if (ret_var.is_owned) {
42731         ret_ref |= 1;
42732 }
42733         return ret_ref;
42734 }
42735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42736         LDKChannelInfo arg_conv;
42737         arg_conv.inner = (void*)(arg & (~1));
42738         arg_conv.is_owned = false;
42739         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42740         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
42741         return ret_conv;
42742 }
42743
42744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42745         LDKChannelInfo orig_conv;
42746         orig_conv.inner = (void*)(orig & (~1));
42747         orig_conv.is_owned = false;
42748         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42749         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
42750         int64_t ret_ref = 0;
42751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42754         ret_ref = (uintptr_t)ret_var.inner;
42755         if (ret_var.is_owned) {
42756                 ret_ref |= 1;
42757         }
42758         return ret_ref;
42759 }
42760
42761 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) {
42762         LDKChannelInfo this_arg_conv;
42763         this_arg_conv.inner = (void*)(this_arg & (~1));
42764         this_arg_conv.is_owned = false;
42765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42766         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
42767         int64_t ret_ref = 0;
42768         if ((uintptr_t)ret_var.inner > 4096) {
42769                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42770                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42772                 ret_ref = (uintptr_t)ret_var.inner;
42773                 if (ret_var.is_owned) {
42774                         ret_ref |= 1;
42775                 }
42776         }
42777         return ret_ref;
42778 }
42779
42780 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
42781         LDKChannelInfo obj_conv;
42782         obj_conv.inner = (void*)(obj & (~1));
42783         obj_conv.is_owned = false;
42784         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42785         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
42786         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42787         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42788         CVec_u8Z_free(ret_var);
42789         return ret_arr;
42790 }
42791
42792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42793         LDKu8slice ser_ref;
42794         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42795         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42796         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
42797         *ret_conv = ChannelInfo_read(ser_ref);
42798         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42799         return (int64_t)ret_conv;
42800 }
42801
42802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42803         LDKDirectedChannelInfo this_obj_conv;
42804         this_obj_conv.inner = (void*)(this_obj & (~1));
42805         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42807         DirectedChannelInfo_free(this_obj_conv);
42808 }
42809
42810 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
42811         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
42812 int64_t ret_ref = 0;
42813 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42814 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42815 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42816 ret_ref = (uintptr_t)ret_var.inner;
42817 if (ret_var.is_owned) {
42818         ret_ref |= 1;
42819 }
42820         return ret_ref;
42821 }
42822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42823         LDKDirectedChannelInfo arg_conv;
42824         arg_conv.inner = (void*)(arg & (~1));
42825         arg_conv.is_owned = false;
42826         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42827         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
42828         return ret_conv;
42829 }
42830
42831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42832         LDKDirectedChannelInfo orig_conv;
42833         orig_conv.inner = (void*)(orig & (~1));
42834         orig_conv.is_owned = false;
42835         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42836         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
42837         int64_t ret_ref = 0;
42838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42841         ret_ref = (uintptr_t)ret_var.inner;
42842         if (ret_var.is_owned) {
42843                 ret_ref |= 1;
42844         }
42845         return ret_ref;
42846 }
42847
42848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
42849         LDKDirectedChannelInfo this_arg_conv;
42850         this_arg_conv.inner = (void*)(this_arg & (~1));
42851         this_arg_conv.is_owned = false;
42852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42853         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
42854         int64_t ret_ref = 0;
42855         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42856         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42858         ret_ref = (uintptr_t)ret_var.inner;
42859         if (ret_var.is_owned) {
42860                 ret_ref |= 1;
42861         }
42862         return ret_ref;
42863 }
42864
42865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
42866         LDKDirectedChannelInfo this_arg_conv;
42867         this_arg_conv.inner = (void*)(this_arg & (~1));
42868         this_arg_conv.is_owned = false;
42869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42870         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
42871         int64_t ret_ref = 0;
42872         if ((uintptr_t)ret_var.inner > 4096) {
42873                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42874                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42876                 ret_ref = (uintptr_t)ret_var.inner;
42877                 if (ret_var.is_owned) {
42878                         ret_ref |= 1;
42879                 }
42880         }
42881         return ret_ref;
42882 }
42883
42884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
42885         LDKDirectedChannelInfo this_arg_conv;
42886         this_arg_conv.inner = (void*)(this_arg & (~1));
42887         this_arg_conv.is_owned = false;
42888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42889         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
42890         return ret_conv;
42891 }
42892
42893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
42894         LDKDirectedChannelInfo this_arg_conv;
42895         this_arg_conv.inner = (void*)(this_arg & (~1));
42896         this_arg_conv.is_owned = false;
42897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42898         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42899         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
42900         int64_t ret_ref = (uintptr_t)ret_copy;
42901         return ret_ref;
42902 }
42903
42904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42905         if ((this_ptr & 1) != 0) return;
42906         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42907         CHECK_ACCESS(this_ptr_ptr);
42908         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
42909         FREE((void*)this_ptr);
42910         EffectiveCapacity_free(this_ptr_conv);
42911 }
42912
42913 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
42914         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42915         *ret_copy = EffectiveCapacity_clone(arg);
42916 int64_t ret_ref = (uintptr_t)ret_copy;
42917         return ret_ref;
42918 }
42919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42920         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
42921         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
42922         return ret_conv;
42923 }
42924
42925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42926         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
42927         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42928         *ret_copy = EffectiveCapacity_clone(orig_conv);
42929         int64_t ret_ref = (uintptr_t)ret_copy;
42930         return ret_ref;
42931 }
42932
42933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
42934         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42935         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
42936         int64_t ret_ref = (uintptr_t)ret_copy;
42937         return ret_ref;
42938 }
42939
42940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
42941         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42942         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
42943         int64_t ret_ref = (uintptr_t)ret_copy;
42944         return ret_ref;
42945 }
42946
42947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
42948         void* htlc_maximum_msat_ptr = (void*)(((uintptr_t)htlc_maximum_msat) & ~1);
42949         CHECK_ACCESS(htlc_maximum_msat_ptr);
42950         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
42951         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat) & ~1));
42952         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42953         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
42954         int64_t ret_ref = (uintptr_t)ret_copy;
42955         return ret_ref;
42956 }
42957
42958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
42959         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42960         *ret_copy = EffectiveCapacity_infinite();
42961         int64_t ret_ref = (uintptr_t)ret_copy;
42962         return ret_ref;
42963 }
42964
42965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
42966         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
42967         *ret_copy = EffectiveCapacity_unknown();
42968         int64_t ret_ref = (uintptr_t)ret_copy;
42969         return ret_ref;
42970 }
42971
42972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
42973         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
42974         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
42975         return ret_conv;
42976 }
42977
42978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42979         LDKRoutingFees this_obj_conv;
42980         this_obj_conv.inner = (void*)(this_obj & (~1));
42981         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42983         RoutingFees_free(this_obj_conv);
42984 }
42985
42986 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42987         LDKRoutingFees this_ptr_conv;
42988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42989         this_ptr_conv.is_owned = false;
42990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42991         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
42992         return ret_conv;
42993 }
42994
42995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42996         LDKRoutingFees this_ptr_conv;
42997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42998         this_ptr_conv.is_owned = false;
42999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43000         RoutingFees_set_base_msat(&this_ptr_conv, val);
43001 }
43002
43003 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
43004         LDKRoutingFees this_ptr_conv;
43005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43006         this_ptr_conv.is_owned = false;
43007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43008         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
43009         return ret_conv;
43010 }
43011
43012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43013         LDKRoutingFees this_ptr_conv;
43014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43015         this_ptr_conv.is_owned = false;
43016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43017         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
43018 }
43019
43020 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) {
43021         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
43022         int64_t ret_ref = 0;
43023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43026         ret_ref = (uintptr_t)ret_var.inner;
43027         if (ret_var.is_owned) {
43028                 ret_ref |= 1;
43029         }
43030         return ret_ref;
43031 }
43032
43033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43034         LDKRoutingFees a_conv;
43035         a_conv.inner = (void*)(a & (~1));
43036         a_conv.is_owned = false;
43037         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43038         LDKRoutingFees b_conv;
43039         b_conv.inner = (void*)(b & (~1));
43040         b_conv.is_owned = false;
43041         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43042         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
43043         return ret_conv;
43044 }
43045
43046 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
43047         LDKRoutingFees ret_var = RoutingFees_clone(arg);
43048 int64_t ret_ref = 0;
43049 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43050 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43051 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43052 ret_ref = (uintptr_t)ret_var.inner;
43053 if (ret_var.is_owned) {
43054         ret_ref |= 1;
43055 }
43056         return ret_ref;
43057 }
43058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43059         LDKRoutingFees arg_conv;
43060         arg_conv.inner = (void*)(arg & (~1));
43061         arg_conv.is_owned = false;
43062         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43063         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
43064         return ret_conv;
43065 }
43066
43067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43068         LDKRoutingFees orig_conv;
43069         orig_conv.inner = (void*)(orig & (~1));
43070         orig_conv.is_owned = false;
43071         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43072         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
43073         int64_t ret_ref = 0;
43074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43077         ret_ref = (uintptr_t)ret_var.inner;
43078         if (ret_var.is_owned) {
43079                 ret_ref |= 1;
43080         }
43081         return ret_ref;
43082 }
43083
43084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
43085         LDKRoutingFees o_conv;
43086         o_conv.inner = (void*)(o & (~1));
43087         o_conv.is_owned = false;
43088         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43089         int64_t ret_conv = RoutingFees_hash(&o_conv);
43090         return ret_conv;
43091 }
43092
43093 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
43094         LDKRoutingFees obj_conv;
43095         obj_conv.inner = (void*)(obj & (~1));
43096         obj_conv.is_owned = false;
43097         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43098         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
43099         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43100         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43101         CVec_u8Z_free(ret_var);
43102         return ret_arr;
43103 }
43104
43105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43106         LDKu8slice ser_ref;
43107         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43108         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43109         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
43110         *ret_conv = RoutingFees_read(ser_ref);
43111         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43112         return (int64_t)ret_conv;
43113 }
43114
43115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43116         LDKNodeAnnouncementInfo this_obj_conv;
43117         this_obj_conv.inner = (void*)(this_obj & (~1));
43118         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43120         NodeAnnouncementInfo_free(this_obj_conv);
43121 }
43122
43123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43124         LDKNodeAnnouncementInfo this_ptr_conv;
43125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43126         this_ptr_conv.is_owned = false;
43127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43128         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
43129         int64_t ret_ref = 0;
43130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43133         ret_ref = (uintptr_t)ret_var.inner;
43134         if (ret_var.is_owned) {
43135                 ret_ref |= 1;
43136         }
43137         return ret_ref;
43138 }
43139
43140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43141         LDKNodeAnnouncementInfo this_ptr_conv;
43142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43143         this_ptr_conv.is_owned = false;
43144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43145         LDKNodeFeatures val_conv;
43146         val_conv.inner = (void*)(val & (~1));
43147         val_conv.is_owned = (val & 1) || (val == 0);
43148         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43149         val_conv = NodeFeatures_clone(&val_conv);
43150         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
43151 }
43152
43153 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
43154         LDKNodeAnnouncementInfo this_ptr_conv;
43155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43156         this_ptr_conv.is_owned = false;
43157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43158         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
43159         return ret_conv;
43160 }
43161
43162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43163         LDKNodeAnnouncementInfo this_ptr_conv;
43164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43165         this_ptr_conv.is_owned = false;
43166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43167         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
43168 }
43169
43170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
43171         LDKNodeAnnouncementInfo this_ptr_conv;
43172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43173         this_ptr_conv.is_owned = false;
43174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43175         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
43176         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
43177         return ret_arr;
43178 }
43179
43180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43181         LDKNodeAnnouncementInfo this_ptr_conv;
43182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43183         this_ptr_conv.is_owned = false;
43184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43185         LDKThreeBytes val_ref;
43186         CHECK((*env)->GetArrayLength(env, val) == 3);
43187         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
43188         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
43189 }
43190
43191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
43192         LDKNodeAnnouncementInfo this_ptr_conv;
43193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43194         this_ptr_conv.is_owned = false;
43195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43196         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
43197         int64_t ret_ref = 0;
43198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43201         ret_ref = (uintptr_t)ret_var.inner;
43202         if (ret_var.is_owned) {
43203                 ret_ref |= 1;
43204         }
43205         return ret_ref;
43206 }
43207
43208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43209         LDKNodeAnnouncementInfo this_ptr_conv;
43210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43211         this_ptr_conv.is_owned = false;
43212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43213         LDKNodeAlias val_conv;
43214         val_conv.inner = (void*)(val & (~1));
43215         val_conv.is_owned = (val & 1) || (val == 0);
43216         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43217         val_conv = NodeAlias_clone(&val_conv);
43218         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
43219 }
43220
43221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
43222         LDKNodeAnnouncementInfo this_ptr_conv;
43223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43224         this_ptr_conv.is_owned = false;
43225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43226         LDKCVec_NetAddressZ val_constr;
43227         val_constr.datalen = (*env)->GetArrayLength(env, val);
43228         if (val_constr.datalen > 0)
43229                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
43230         else
43231                 val_constr.data = NULL;
43232         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
43233         for (size_t m = 0; m < val_constr.datalen; m++) {
43234                 int64_t val_conv_12 = val_vals[m];
43235                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
43236                 CHECK_ACCESS(val_conv_12_ptr);
43237                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
43238                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
43239                 val_constr.data[m] = val_conv_12_conv;
43240         }
43241         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
43242         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
43243 }
43244
43245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43246         LDKNodeAnnouncementInfo this_ptr_conv;
43247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43248         this_ptr_conv.is_owned = false;
43249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43250         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
43251         int64_t ret_ref = 0;
43252         if ((uintptr_t)ret_var.inner > 4096) {
43253                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43254                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43256                 ret_ref = (uintptr_t)ret_var.inner;
43257                 if (ret_var.is_owned) {
43258                         ret_ref |= 1;
43259                 }
43260         }
43261         return ret_ref;
43262 }
43263
43264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43265         LDKNodeAnnouncementInfo this_ptr_conv;
43266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43267         this_ptr_conv.is_owned = false;
43268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43269         LDKNodeAnnouncement val_conv;
43270         val_conv.inner = (void*)(val & (~1));
43271         val_conv.is_owned = (val & 1) || (val == 0);
43272         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43273         val_conv = NodeAnnouncement_clone(&val_conv);
43274         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
43275 }
43276
43277 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) {
43278         LDKNodeFeatures features_arg_conv;
43279         features_arg_conv.inner = (void*)(features_arg & (~1));
43280         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
43281         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
43282         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
43283         LDKThreeBytes rgb_arg_ref;
43284         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
43285         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
43286         LDKNodeAlias alias_arg_conv;
43287         alias_arg_conv.inner = (void*)(alias_arg & (~1));
43288         alias_arg_conv.is_owned = (alias_arg & 1) || (alias_arg == 0);
43289         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
43290         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
43291         LDKCVec_NetAddressZ addresses_arg_constr;
43292         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
43293         if (addresses_arg_constr.datalen > 0)
43294                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
43295         else
43296                 addresses_arg_constr.data = NULL;
43297         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
43298         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
43299                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
43300                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
43301                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
43302                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
43303                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
43304         }
43305         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
43306         LDKNodeAnnouncement announcement_message_arg_conv;
43307         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
43308         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
43309         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
43310         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
43311         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
43312         int64_t ret_ref = 0;
43313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43316         ret_ref = (uintptr_t)ret_var.inner;
43317         if (ret_var.is_owned) {
43318                 ret_ref |= 1;
43319         }
43320         return ret_ref;
43321 }
43322
43323 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
43324         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
43325 int64_t ret_ref = 0;
43326 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43327 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43328 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43329 ret_ref = (uintptr_t)ret_var.inner;
43330 if (ret_var.is_owned) {
43331         ret_ref |= 1;
43332 }
43333         return ret_ref;
43334 }
43335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43336         LDKNodeAnnouncementInfo arg_conv;
43337         arg_conv.inner = (void*)(arg & (~1));
43338         arg_conv.is_owned = false;
43339         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43340         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
43341         return ret_conv;
43342 }
43343
43344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43345         LDKNodeAnnouncementInfo orig_conv;
43346         orig_conv.inner = (void*)(orig & (~1));
43347         orig_conv.is_owned = false;
43348         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43349         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
43350         int64_t ret_ref = 0;
43351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43354         ret_ref = (uintptr_t)ret_var.inner;
43355         if (ret_var.is_owned) {
43356                 ret_ref |= 1;
43357         }
43358         return ret_ref;
43359 }
43360
43361 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43362         LDKNodeAnnouncementInfo obj_conv;
43363         obj_conv.inner = (void*)(obj & (~1));
43364         obj_conv.is_owned = false;
43365         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43366         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
43367         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43368         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43369         CVec_u8Z_free(ret_var);
43370         return ret_arr;
43371 }
43372
43373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43374         LDKu8slice ser_ref;
43375         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43376         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43377         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
43378         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
43379         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43380         return (int64_t)ret_conv;
43381 }
43382
43383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43384         LDKNodeAlias this_obj_conv;
43385         this_obj_conv.inner = (void*)(this_obj & (~1));
43386         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43388         NodeAlias_free(this_obj_conv);
43389 }
43390
43391 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
43392         LDKNodeAlias this_ptr_conv;
43393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43394         this_ptr_conv.is_owned = false;
43395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43396         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43397         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
43398         return ret_arr;
43399 }
43400
43401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43402         LDKNodeAlias this_ptr_conv;
43403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43404         this_ptr_conv.is_owned = false;
43405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43406         LDKThirtyTwoBytes val_ref;
43407         CHECK((*env)->GetArrayLength(env, val) == 32);
43408         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
43409         NodeAlias_set_a(&this_ptr_conv, val_ref);
43410 }
43411
43412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
43413         LDKThirtyTwoBytes a_arg_ref;
43414         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
43415         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
43416         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
43417         int64_t ret_ref = 0;
43418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43421         ret_ref = (uintptr_t)ret_var.inner;
43422         if (ret_var.is_owned) {
43423                 ret_ref |= 1;
43424         }
43425         return ret_ref;
43426 }
43427
43428 static inline uintptr_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
43429         LDKNodeAlias ret_var = NodeAlias_clone(arg);
43430 int64_t ret_ref = 0;
43431 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43432 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43433 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43434 ret_ref = (uintptr_t)ret_var.inner;
43435 if (ret_var.is_owned) {
43436         ret_ref |= 1;
43437 }
43438         return ret_ref;
43439 }
43440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43441         LDKNodeAlias arg_conv;
43442         arg_conv.inner = (void*)(arg & (~1));
43443         arg_conv.is_owned = false;
43444         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43445         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
43446         return ret_conv;
43447 }
43448
43449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43450         LDKNodeAlias orig_conv;
43451         orig_conv.inner = (void*)(orig & (~1));
43452         orig_conv.is_owned = false;
43453         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43454         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
43455         int64_t ret_ref = 0;
43456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43459         ret_ref = (uintptr_t)ret_var.inner;
43460         if (ret_var.is_owned) {
43461                 ret_ref |= 1;
43462         }
43463         return ret_ref;
43464 }
43465
43466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
43467         LDKNodeAlias obj_conv;
43468         obj_conv.inner = (void*)(obj & (~1));
43469         obj_conv.is_owned = false;
43470         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43471         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
43472         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43473         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43474         CVec_u8Z_free(ret_var);
43475         return ret_arr;
43476 }
43477
43478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43479         LDKu8slice ser_ref;
43480         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43481         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43482         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
43483         *ret_conv = NodeAlias_read(ser_ref);
43484         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43485         return (int64_t)ret_conv;
43486 }
43487
43488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43489         LDKNodeInfo this_obj_conv;
43490         this_obj_conv.inner = (void*)(this_obj & (~1));
43491         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43493         NodeInfo_free(this_obj_conv);
43494 }
43495
43496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
43497         LDKNodeInfo this_ptr_conv;
43498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43499         this_ptr_conv.is_owned = false;
43500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43501         LDKCVec_u64Z val_constr;
43502         val_constr.datalen = (*env)->GetArrayLength(env, val);
43503         if (val_constr.datalen > 0)
43504                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
43505         else
43506                 val_constr.data = NULL;
43507         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
43508         for (size_t g = 0; g < val_constr.datalen; g++) {
43509                 int64_t val_conv_6 = val_vals[g];
43510                 val_constr.data[g] = val_conv_6;
43511         }
43512         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
43513         NodeInfo_set_channels(&this_ptr_conv, val_constr);
43514 }
43515
43516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
43517         LDKNodeInfo this_ptr_conv;
43518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43519         this_ptr_conv.is_owned = false;
43520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43521         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
43522         int64_t ret_ref = 0;
43523         if ((uintptr_t)ret_var.inner > 4096) {
43524                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43525                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43527                 ret_ref = (uintptr_t)ret_var.inner;
43528                 if (ret_var.is_owned) {
43529                         ret_ref |= 1;
43530                 }
43531         }
43532         return ret_ref;
43533 }
43534
43535 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) {
43536         LDKNodeInfo this_ptr_conv;
43537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43538         this_ptr_conv.is_owned = false;
43539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43540         LDKRoutingFees val_conv;
43541         val_conv.inner = (void*)(val & (~1));
43542         val_conv.is_owned = (val & 1) || (val == 0);
43543         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43544         val_conv = RoutingFees_clone(&val_conv);
43545         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
43546 }
43547
43548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
43549         LDKNodeInfo this_ptr_conv;
43550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43551         this_ptr_conv.is_owned = false;
43552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43553         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
43554         int64_t ret_ref = 0;
43555         if ((uintptr_t)ret_var.inner > 4096) {
43556                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43557                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43559                 ret_ref = (uintptr_t)ret_var.inner;
43560                 if (ret_var.is_owned) {
43561                         ret_ref |= 1;
43562                 }
43563         }
43564         return ret_ref;
43565 }
43566
43567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43568         LDKNodeInfo this_ptr_conv;
43569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43570         this_ptr_conv.is_owned = false;
43571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43572         LDKNodeAnnouncementInfo val_conv;
43573         val_conv.inner = (void*)(val & (~1));
43574         val_conv.is_owned = (val & 1) || (val == 0);
43575         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43576         val_conv = NodeAnnouncementInfo_clone(&val_conv);
43577         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
43578 }
43579
43580 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) {
43581         LDKCVec_u64Z channels_arg_constr;
43582         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
43583         if (channels_arg_constr.datalen > 0)
43584                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
43585         else
43586                 channels_arg_constr.data = NULL;
43587         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
43588         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
43589                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
43590                 channels_arg_constr.data[g] = channels_arg_conv_6;
43591         }
43592         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
43593         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
43594         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
43595         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
43596         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
43597         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
43598         LDKNodeAnnouncementInfo announcement_info_arg_conv;
43599         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
43600         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
43601         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
43602         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
43603         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
43604         int64_t ret_ref = 0;
43605         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43606         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43608         ret_ref = (uintptr_t)ret_var.inner;
43609         if (ret_var.is_owned) {
43610                 ret_ref |= 1;
43611         }
43612         return ret_ref;
43613 }
43614
43615 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
43616         LDKNodeInfo ret_var = NodeInfo_clone(arg);
43617 int64_t ret_ref = 0;
43618 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43619 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43620 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43621 ret_ref = (uintptr_t)ret_var.inner;
43622 if (ret_var.is_owned) {
43623         ret_ref |= 1;
43624 }
43625         return ret_ref;
43626 }
43627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43628         LDKNodeInfo arg_conv;
43629         arg_conv.inner = (void*)(arg & (~1));
43630         arg_conv.is_owned = false;
43631         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43632         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
43633         return ret_conv;
43634 }
43635
43636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43637         LDKNodeInfo orig_conv;
43638         orig_conv.inner = (void*)(orig & (~1));
43639         orig_conv.is_owned = false;
43640         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43641         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
43642         int64_t ret_ref = 0;
43643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43646         ret_ref = (uintptr_t)ret_var.inner;
43647         if (ret_var.is_owned) {
43648                 ret_ref |= 1;
43649         }
43650         return ret_ref;
43651 }
43652
43653 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43654         LDKNodeInfo obj_conv;
43655         obj_conv.inner = (void*)(obj & (~1));
43656         obj_conv.is_owned = false;
43657         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43658         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
43659         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43660         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43661         CVec_u8Z_free(ret_var);
43662         return ret_arr;
43663 }
43664
43665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43666         LDKu8slice ser_ref;
43667         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43668         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43669         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
43670         *ret_conv = NodeInfo_read(ser_ref);
43671         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43672         return (int64_t)ret_conv;
43673 }
43674
43675 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
43676         LDKNetworkGraph obj_conv;
43677         obj_conv.inner = (void*)(obj & (~1));
43678         obj_conv.is_owned = false;
43679         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43680         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
43681         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43682         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43683         CVec_u8Z_free(ret_var);
43684         return ret_arr;
43685 }
43686
43687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
43688         LDKu8slice ser_ref;
43689         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43690         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43691         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
43692         CHECK_ACCESS(arg_ptr);
43693         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
43694         if (arg_conv.free == LDKLogger_JCalls_free) {
43695                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43696                 LDKLogger_JCalls_cloned(&arg_conv);
43697         }
43698         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
43699         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
43700         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43701         return (int64_t)ret_conv;
43702 }
43703
43704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
43705         LDKThirtyTwoBytes genesis_hash_ref;
43706         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
43707         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
43708         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43709         CHECK_ACCESS(logger_ptr);
43710         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43711         if (logger_conv.free == LDKLogger_JCalls_free) {
43712                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43713                 LDKLogger_JCalls_cloned(&logger_conv);
43714         }
43715         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
43716         int64_t ret_ref = 0;
43717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43720         ret_ref = (uintptr_t)ret_var.inner;
43721         if (ret_var.is_owned) {
43722                 ret_ref |= 1;
43723         }
43724         return ret_ref;
43725 }
43726
43727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
43728         LDKNetworkGraph this_arg_conv;
43729         this_arg_conv.inner = (void*)(this_arg & (~1));
43730         this_arg_conv.is_owned = false;
43731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43732         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
43733         int64_t ret_ref = 0;
43734         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43735         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43737         ret_ref = (uintptr_t)ret_var.inner;
43738         if (ret_var.is_owned) {
43739                 ret_ref |= 1;
43740         }
43741         return ret_ref;
43742 }
43743
43744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
43745         LDKNetworkGraph this_arg_conv;
43746         this_arg_conv.inner = (void*)(this_arg & (~1));
43747         this_arg_conv.is_owned = false;
43748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43749         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
43750         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
43751         int64_t ret_ref = (uintptr_t)ret_copy;
43752         return ret_ref;
43753 }
43754
43755 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) {
43756         LDKNetworkGraph this_arg_conv;
43757         this_arg_conv.inner = (void*)(this_arg & (~1));
43758         this_arg_conv.is_owned = false;
43759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43760         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
43761 }
43762
43763 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) {
43764         LDKNetworkGraph this_arg_conv;
43765         this_arg_conv.inner = (void*)(this_arg & (~1));
43766         this_arg_conv.is_owned = false;
43767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43768         LDKNodeAnnouncement msg_conv;
43769         msg_conv.inner = (void*)(msg & (~1));
43770         msg_conv.is_owned = false;
43771         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43772         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43773         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
43774         return (int64_t)ret_conv;
43775 }
43776
43777 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) {
43778         LDKNetworkGraph this_arg_conv;
43779         this_arg_conv.inner = (void*)(this_arg & (~1));
43780         this_arg_conv.is_owned = false;
43781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43782         LDKUnsignedNodeAnnouncement msg_conv;
43783         msg_conv.inner = (void*)(msg & (~1));
43784         msg_conv.is_owned = false;
43785         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43786         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43787         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
43788         return (int64_t)ret_conv;
43789 }
43790
43791 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) {
43792         LDKNetworkGraph this_arg_conv;
43793         this_arg_conv.inner = (void*)(this_arg & (~1));
43794         this_arg_conv.is_owned = false;
43795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43796         LDKChannelAnnouncement msg_conv;
43797         msg_conv.inner = (void*)(msg & (~1));
43798         msg_conv.is_owned = false;
43799         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43800         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
43801         CHECK_ACCESS(chain_access_ptr);
43802         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43803         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43804         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43805                 // Manually implement clone for Java trait instances
43806                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43807                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43808                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43809                 }
43810         }
43811         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43812         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
43813         return (int64_t)ret_conv;
43814 }
43815
43816 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) {
43817         LDKNetworkGraph this_arg_conv;
43818         this_arg_conv.inner = (void*)(this_arg & (~1));
43819         this_arg_conv.is_owned = false;
43820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43821         LDKUnsignedChannelAnnouncement msg_conv;
43822         msg_conv.inner = (void*)(msg & (~1));
43823         msg_conv.is_owned = false;
43824         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43825         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
43826         CHECK_ACCESS(chain_access_ptr);
43827         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43828         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43829         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43830                 // Manually implement clone for Java trait instances
43831                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43832                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43833                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43834                 }
43835         }
43836         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43837         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
43838         return (int64_t)ret_conv;
43839 }
43840
43841 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) {
43842         LDKNetworkGraph this_arg_conv;
43843         this_arg_conv.inner = (void*)(this_arg & (~1));
43844         this_arg_conv.is_owned = false;
43845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43846         LDKChannelFeatures features_conv;
43847         features_conv.inner = (void*)(features & (~1));
43848         features_conv.is_owned = (features & 1) || (features == 0);
43849         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
43850         features_conv = ChannelFeatures_clone(&features_conv);
43851         LDKPublicKey node_id_1_ref;
43852         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
43853         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
43854         LDKPublicKey node_id_2_ref;
43855         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
43856         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
43857         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43858         *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);
43859         return (int64_t)ret_conv;
43860 }
43861
43862 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) {
43863         LDKNetworkGraph this_arg_conv;
43864         this_arg_conv.inner = (void*)(this_arg & (~1));
43865         this_arg_conv.is_owned = false;
43866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43867         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
43868 }
43869
43870 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) {
43871         LDKNetworkGraph this_arg_conv;
43872         this_arg_conv.inner = (void*)(this_arg & (~1));
43873         this_arg_conv.is_owned = false;
43874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43875         LDKPublicKey _node_id_ref;
43876         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
43877         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
43878         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
43879 }
43880
43881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
43882         LDKNetworkGraph this_arg_conv;
43883         this_arg_conv.inner = (void*)(this_arg & (~1));
43884         this_arg_conv.is_owned = false;
43885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43886         NetworkGraph_remove_stale_channels(&this_arg_conv);
43887 }
43888
43889 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) {
43890         LDKNetworkGraph this_arg_conv;
43891         this_arg_conv.inner = (void*)(this_arg & (~1));
43892         this_arg_conv.is_owned = false;
43893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43894         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
43895 }
43896
43897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
43898         LDKNetworkGraph this_arg_conv;
43899         this_arg_conv.inner = (void*)(this_arg & (~1));
43900         this_arg_conv.is_owned = false;
43901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43902         LDKChannelUpdate msg_conv;
43903         msg_conv.inner = (void*)(msg & (~1));
43904         msg_conv.is_owned = false;
43905         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43906         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43907         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
43908         return (int64_t)ret_conv;
43909 }
43910
43911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
43912         LDKNetworkGraph this_arg_conv;
43913         this_arg_conv.inner = (void*)(this_arg & (~1));
43914         this_arg_conv.is_owned = false;
43915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43916         LDKUnsignedChannelUpdate msg_conv;
43917         msg_conv.inner = (void*)(msg & (~1));
43918         msg_conv.is_owned = false;
43919         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43920         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
43921         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
43922         return (int64_t)ret_conv;
43923 }
43924
43925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
43926         LDKReadOnlyNetworkGraph this_arg_conv;
43927         this_arg_conv.inner = (void*)(this_arg & (~1));
43928         this_arg_conv.is_owned = false;
43929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43930         LDKPublicKey pubkey_ref;
43931         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
43932         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
43933         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
43934         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
43935         int64_t ret_ref = (uintptr_t)ret_copy;
43936         return ret_ref;
43937 }
43938
43939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43940         LDKRouteHop this_obj_conv;
43941         this_obj_conv.inner = (void*)(this_obj & (~1));
43942         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43944         RouteHop_free(this_obj_conv);
43945 }
43946
43947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
43948         LDKRouteHop this_ptr_conv;
43949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43950         this_ptr_conv.is_owned = false;
43951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43952         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
43953         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
43954         return ret_arr;
43955 }
43956
43957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43958         LDKRouteHop this_ptr_conv;
43959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43960         this_ptr_conv.is_owned = false;
43961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43962         LDKPublicKey val_ref;
43963         CHECK((*env)->GetArrayLength(env, val) == 33);
43964         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
43965         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
43966 }
43967
43968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43969         LDKRouteHop this_ptr_conv;
43970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43971         this_ptr_conv.is_owned = false;
43972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43973         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
43974         int64_t ret_ref = 0;
43975         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43976         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43978         ret_ref = (uintptr_t)ret_var.inner;
43979         if (ret_var.is_owned) {
43980                 ret_ref |= 1;
43981         }
43982         return ret_ref;
43983 }
43984
43985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43986         LDKRouteHop this_ptr_conv;
43987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43988         this_ptr_conv.is_owned = false;
43989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43990         LDKNodeFeatures val_conv;
43991         val_conv.inner = (void*)(val & (~1));
43992         val_conv.is_owned = (val & 1) || (val == 0);
43993         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43994         val_conv = NodeFeatures_clone(&val_conv);
43995         RouteHop_set_node_features(&this_ptr_conv, val_conv);
43996 }
43997
43998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
43999         LDKRouteHop this_ptr_conv;
44000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44001         this_ptr_conv.is_owned = false;
44002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44003         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
44004         return ret_conv;
44005 }
44006
44007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44008         LDKRouteHop this_ptr_conv;
44009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44010         this_ptr_conv.is_owned = false;
44011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44012         RouteHop_set_short_channel_id(&this_ptr_conv, val);
44013 }
44014
44015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44016         LDKRouteHop this_ptr_conv;
44017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44018         this_ptr_conv.is_owned = false;
44019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44020         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
44021         int64_t ret_ref = 0;
44022         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44023         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44025         ret_ref = (uintptr_t)ret_var.inner;
44026         if (ret_var.is_owned) {
44027                 ret_ref |= 1;
44028         }
44029         return ret_ref;
44030 }
44031
44032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44033         LDKRouteHop this_ptr_conv;
44034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44035         this_ptr_conv.is_owned = false;
44036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44037         LDKChannelFeatures val_conv;
44038         val_conv.inner = (void*)(val & (~1));
44039         val_conv.is_owned = (val & 1) || (val == 0);
44040         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44041         val_conv = ChannelFeatures_clone(&val_conv);
44042         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
44043 }
44044
44045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44046         LDKRouteHop this_ptr_conv;
44047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44048         this_ptr_conv.is_owned = false;
44049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44050         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
44051         return ret_conv;
44052 }
44053
44054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44055         LDKRouteHop this_ptr_conv;
44056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44057         this_ptr_conv.is_owned = false;
44058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44059         RouteHop_set_fee_msat(&this_ptr_conv, val);
44060 }
44061
44062 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44063         LDKRouteHop this_ptr_conv;
44064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44065         this_ptr_conv.is_owned = false;
44066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44067         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
44068         return ret_conv;
44069 }
44070
44071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44072         LDKRouteHop this_ptr_conv;
44073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44074         this_ptr_conv.is_owned = false;
44075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44076         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
44077 }
44078
44079 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) {
44080         LDKPublicKey pubkey_arg_ref;
44081         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
44082         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
44083         LDKNodeFeatures node_features_arg_conv;
44084         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
44085         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
44086         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
44087         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
44088         LDKChannelFeatures channel_features_arg_conv;
44089         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
44090         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
44091         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
44092         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
44093         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);
44094         int64_t ret_ref = 0;
44095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44098         ret_ref = (uintptr_t)ret_var.inner;
44099         if (ret_var.is_owned) {
44100                 ret_ref |= 1;
44101         }
44102         return ret_ref;
44103 }
44104
44105 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
44106         LDKRouteHop ret_var = RouteHop_clone(arg);
44107 int64_t ret_ref = 0;
44108 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44109 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44110 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44111 ret_ref = (uintptr_t)ret_var.inner;
44112 if (ret_var.is_owned) {
44113         ret_ref |= 1;
44114 }
44115         return ret_ref;
44116 }
44117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44118         LDKRouteHop arg_conv;
44119         arg_conv.inner = (void*)(arg & (~1));
44120         arg_conv.is_owned = false;
44121         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44122         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
44123         return ret_conv;
44124 }
44125
44126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44127         LDKRouteHop orig_conv;
44128         orig_conv.inner = (void*)(orig & (~1));
44129         orig_conv.is_owned = false;
44130         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44131         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
44132         int64_t ret_ref = 0;
44133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44136         ret_ref = (uintptr_t)ret_var.inner;
44137         if (ret_var.is_owned) {
44138                 ret_ref |= 1;
44139         }
44140         return ret_ref;
44141 }
44142
44143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
44144         LDKRouteHop o_conv;
44145         o_conv.inner = (void*)(o & (~1));
44146         o_conv.is_owned = false;
44147         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44148         int64_t ret_conv = RouteHop_hash(&o_conv);
44149         return ret_conv;
44150 }
44151
44152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44153         LDKRouteHop a_conv;
44154         a_conv.inner = (void*)(a & (~1));
44155         a_conv.is_owned = false;
44156         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44157         LDKRouteHop b_conv;
44158         b_conv.inner = (void*)(b & (~1));
44159         b_conv.is_owned = false;
44160         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44161         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
44162         return ret_conv;
44163 }
44164
44165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
44166         LDKRouteHop obj_conv;
44167         obj_conv.inner = (void*)(obj & (~1));
44168         obj_conv.is_owned = false;
44169         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44170         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
44171         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44172         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44173         CVec_u8Z_free(ret_var);
44174         return ret_arr;
44175 }
44176
44177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44178         LDKu8slice ser_ref;
44179         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44180         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44181         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
44182         *ret_conv = RouteHop_read(ser_ref);
44183         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44184         return (int64_t)ret_conv;
44185 }
44186
44187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44188         LDKRoute this_obj_conv;
44189         this_obj_conv.inner = (void*)(this_obj & (~1));
44190         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44192         Route_free(this_obj_conv);
44193 }
44194
44195 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
44196         LDKRoute this_ptr_conv;
44197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44198         this_ptr_conv.is_owned = false;
44199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44200         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
44201         jobjectArray ret_arr = NULL;
44202         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
44203         ;
44204         for (size_t m = 0; m < ret_var.datalen; m++) {
44205                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
44206                 int64_tArray ret_conv_12_arr = NULL;
44207                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
44208                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
44209                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
44210                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
44211                         int64_t ret_conv_12_conv_10_ref = 0;
44212                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44213                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44214                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
44215                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
44216                         if (ret_conv_12_conv_10_var.is_owned) {
44217                                 ret_conv_12_conv_10_ref |= 1;
44218                         }
44219                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
44220                 }
44221                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
44222                 FREE(ret_conv_12_var.data);
44223                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
44224         }
44225         
44226         FREE(ret_var.data);
44227         return ret_arr;
44228 }
44229
44230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
44231         LDKRoute this_ptr_conv;
44232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44233         this_ptr_conv.is_owned = false;
44234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44235         LDKCVec_CVec_RouteHopZZ val_constr;
44236         val_constr.datalen = (*env)->GetArrayLength(env, val);
44237         if (val_constr.datalen > 0)
44238                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
44239         else
44240                 val_constr.data = NULL;
44241         for (size_t m = 0; m < val_constr.datalen; m++) {
44242                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
44243                 LDKCVec_RouteHopZ val_conv_12_constr;
44244                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
44245                 if (val_conv_12_constr.datalen > 0)
44246                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
44247                 else
44248                         val_conv_12_constr.data = NULL;
44249                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
44250                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
44251                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
44252                         LDKRouteHop val_conv_12_conv_10_conv;
44253                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
44254                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
44255                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
44256                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
44257                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
44258                 }
44259                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
44260                 val_constr.data[m] = val_conv_12_constr;
44261         }
44262         Route_set_paths(&this_ptr_conv, val_constr);
44263 }
44264
44265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
44266         LDKRoute this_ptr_conv;
44267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44268         this_ptr_conv.is_owned = false;
44269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44270         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
44271         int64_t ret_ref = 0;
44272         if ((uintptr_t)ret_var.inner > 4096) {
44273                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44274                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44276                 ret_ref = (uintptr_t)ret_var.inner;
44277                 if (ret_var.is_owned) {
44278                         ret_ref |= 1;
44279                 }
44280         }
44281         return ret_ref;
44282 }
44283
44284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44285         LDKRoute this_ptr_conv;
44286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44287         this_ptr_conv.is_owned = false;
44288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44289         LDKPaymentParameters val_conv;
44290         val_conv.inner = (void*)(val & (~1));
44291         val_conv.is_owned = (val & 1) || (val == 0);
44292         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44293         val_conv = PaymentParameters_clone(&val_conv);
44294         Route_set_payment_params(&this_ptr_conv, val_conv);
44295 }
44296
44297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
44298         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
44299         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
44300         if (paths_arg_constr.datalen > 0)
44301                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
44302         else
44303                 paths_arg_constr.data = NULL;
44304         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
44305                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
44306                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
44307                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
44308                 if (paths_arg_conv_12_constr.datalen > 0)
44309                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
44310                 else
44311                         paths_arg_conv_12_constr.data = NULL;
44312                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
44313                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
44314                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
44315                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
44316                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
44317                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
44318                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
44319                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
44320                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
44321                 }
44322                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
44323                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
44324         }
44325         LDKPaymentParameters payment_params_arg_conv;
44326         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
44327         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
44328         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
44329         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
44330         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
44331         int64_t ret_ref = 0;
44332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44335         ret_ref = (uintptr_t)ret_var.inner;
44336         if (ret_var.is_owned) {
44337                 ret_ref |= 1;
44338         }
44339         return ret_ref;
44340 }
44341
44342 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
44343         LDKRoute ret_var = Route_clone(arg);
44344 int64_t ret_ref = 0;
44345 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44346 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44347 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44348 ret_ref = (uintptr_t)ret_var.inner;
44349 if (ret_var.is_owned) {
44350         ret_ref |= 1;
44351 }
44352         return ret_ref;
44353 }
44354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44355         LDKRoute arg_conv;
44356         arg_conv.inner = (void*)(arg & (~1));
44357         arg_conv.is_owned = false;
44358         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44359         int64_t ret_conv = Route_clone_ptr(&arg_conv);
44360         return ret_conv;
44361 }
44362
44363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44364         LDKRoute orig_conv;
44365         orig_conv.inner = (void*)(orig & (~1));
44366         orig_conv.is_owned = false;
44367         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44368         LDKRoute ret_var = Route_clone(&orig_conv);
44369         int64_t ret_ref = 0;
44370         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44371         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44373         ret_ref = (uintptr_t)ret_var.inner;
44374         if (ret_var.is_owned) {
44375                 ret_ref |= 1;
44376         }
44377         return ret_ref;
44378 }
44379
44380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
44381         LDKRoute o_conv;
44382         o_conv.inner = (void*)(o & (~1));
44383         o_conv.is_owned = false;
44384         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44385         int64_t ret_conv = Route_hash(&o_conv);
44386         return ret_conv;
44387 }
44388
44389 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44390         LDKRoute a_conv;
44391         a_conv.inner = (void*)(a & (~1));
44392         a_conv.is_owned = false;
44393         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44394         LDKRoute b_conv;
44395         b_conv.inner = (void*)(b & (~1));
44396         b_conv.is_owned = false;
44397         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44398         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
44399         return ret_conv;
44400 }
44401
44402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
44403         LDKRoute this_arg_conv;
44404         this_arg_conv.inner = (void*)(this_arg & (~1));
44405         this_arg_conv.is_owned = false;
44406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44407         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
44408         return ret_conv;
44409 }
44410
44411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
44412         LDKRoute this_arg_conv;
44413         this_arg_conv.inner = (void*)(this_arg & (~1));
44414         this_arg_conv.is_owned = false;
44415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44416         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
44417         return ret_conv;
44418 }
44419
44420 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
44421         LDKRoute obj_conv;
44422         obj_conv.inner = (void*)(obj & (~1));
44423         obj_conv.is_owned = false;
44424         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44425         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
44426         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44427         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44428         CVec_u8Z_free(ret_var);
44429         return ret_arr;
44430 }
44431
44432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44433         LDKu8slice ser_ref;
44434         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44435         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44436         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
44437         *ret_conv = Route_read(ser_ref);
44438         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44439         return (int64_t)ret_conv;
44440 }
44441
44442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44443         LDKRouteParameters this_obj_conv;
44444         this_obj_conv.inner = (void*)(this_obj & (~1));
44445         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44447         RouteParameters_free(this_obj_conv);
44448 }
44449
44450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
44451         LDKRouteParameters this_ptr_conv;
44452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44453         this_ptr_conv.is_owned = false;
44454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44455         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
44456         int64_t ret_ref = 0;
44457         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44458         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44460         ret_ref = (uintptr_t)ret_var.inner;
44461         if (ret_var.is_owned) {
44462                 ret_ref |= 1;
44463         }
44464         return ret_ref;
44465 }
44466
44467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44468         LDKRouteParameters this_ptr_conv;
44469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44470         this_ptr_conv.is_owned = false;
44471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44472         LDKPaymentParameters val_conv;
44473         val_conv.inner = (void*)(val & (~1));
44474         val_conv.is_owned = (val & 1) || (val == 0);
44475         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44476         val_conv = PaymentParameters_clone(&val_conv);
44477         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
44478 }
44479
44480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44481         LDKRouteParameters this_ptr_conv;
44482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44483         this_ptr_conv.is_owned = false;
44484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44485         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
44486         return ret_conv;
44487 }
44488
44489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44490         LDKRouteParameters this_ptr_conv;
44491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44492         this_ptr_conv.is_owned = false;
44493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44494         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
44495 }
44496
44497 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44498         LDKRouteParameters this_ptr_conv;
44499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44500         this_ptr_conv.is_owned = false;
44501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44502         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
44503         return ret_conv;
44504 }
44505
44506 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) {
44507         LDKRouteParameters this_ptr_conv;
44508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44509         this_ptr_conv.is_owned = false;
44510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44511         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
44512 }
44513
44514 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) {
44515         LDKPaymentParameters payment_params_arg_conv;
44516         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
44517         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
44518         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
44519         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
44520         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
44521         int64_t ret_ref = 0;
44522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44525         ret_ref = (uintptr_t)ret_var.inner;
44526         if (ret_var.is_owned) {
44527                 ret_ref |= 1;
44528         }
44529         return ret_ref;
44530 }
44531
44532 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
44533         LDKRouteParameters ret_var = RouteParameters_clone(arg);
44534 int64_t ret_ref = 0;
44535 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44536 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44537 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44538 ret_ref = (uintptr_t)ret_var.inner;
44539 if (ret_var.is_owned) {
44540         ret_ref |= 1;
44541 }
44542         return ret_ref;
44543 }
44544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44545         LDKRouteParameters arg_conv;
44546         arg_conv.inner = (void*)(arg & (~1));
44547         arg_conv.is_owned = false;
44548         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44549         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
44550         return ret_conv;
44551 }
44552
44553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44554         LDKRouteParameters orig_conv;
44555         orig_conv.inner = (void*)(orig & (~1));
44556         orig_conv.is_owned = false;
44557         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44558         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
44559         int64_t ret_ref = 0;
44560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44563         ret_ref = (uintptr_t)ret_var.inner;
44564         if (ret_var.is_owned) {
44565                 ret_ref |= 1;
44566         }
44567         return ret_ref;
44568 }
44569
44570 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
44571         LDKRouteParameters obj_conv;
44572         obj_conv.inner = (void*)(obj & (~1));
44573         obj_conv.is_owned = false;
44574         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44575         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
44576         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44577         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44578         CVec_u8Z_free(ret_var);
44579         return ret_arr;
44580 }
44581
44582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44583         LDKu8slice ser_ref;
44584         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44585         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44586         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
44587         *ret_conv = RouteParameters_read(ser_ref);
44588         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44589         return (int64_t)ret_conv;
44590 }
44591
44592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44593         LDKPaymentParameters this_obj_conv;
44594         this_obj_conv.inner = (void*)(this_obj & (~1));
44595         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44597         PaymentParameters_free(this_obj_conv);
44598 }
44599
44600 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
44601         LDKPaymentParameters this_ptr_conv;
44602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44603         this_ptr_conv.is_owned = false;
44604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44605         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44606         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
44607         return ret_arr;
44608 }
44609
44610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44611         LDKPaymentParameters this_ptr_conv;
44612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44613         this_ptr_conv.is_owned = false;
44614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44615         LDKPublicKey val_ref;
44616         CHECK((*env)->GetArrayLength(env, val) == 33);
44617         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44618         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
44619 }
44620
44621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44622         LDKPaymentParameters this_ptr_conv;
44623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44624         this_ptr_conv.is_owned = false;
44625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44626         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
44627         int64_t ret_ref = 0;
44628         if ((uintptr_t)ret_var.inner > 4096) {
44629                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44630                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44632                 ret_ref = (uintptr_t)ret_var.inner;
44633                 if (ret_var.is_owned) {
44634                         ret_ref |= 1;
44635                 }
44636         }
44637         return ret_ref;
44638 }
44639
44640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44641         LDKPaymentParameters this_ptr_conv;
44642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44643         this_ptr_conv.is_owned = false;
44644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44645         LDKInvoiceFeatures val_conv;
44646         val_conv.inner = (void*)(val & (~1));
44647         val_conv.is_owned = (val & 1) || (val == 0);
44648         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44649         val_conv = InvoiceFeatures_clone(&val_conv);
44650         PaymentParameters_set_features(&this_ptr_conv, val_conv);
44651 }
44652
44653 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
44654         LDKPaymentParameters this_ptr_conv;
44655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44656         this_ptr_conv.is_owned = false;
44657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44658         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
44659         int64_tArray ret_arr = NULL;
44660         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44661         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44662         for (size_t l = 0; l < ret_var.datalen; l++) {
44663                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
44664                 int64_t ret_conv_11_ref = 0;
44665                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44666                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44667                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
44668                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
44669                 if (ret_conv_11_var.is_owned) {
44670                         ret_conv_11_ref |= 1;
44671                 }
44672                 ret_arr_ptr[l] = ret_conv_11_ref;
44673         }
44674         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44675         FREE(ret_var.data);
44676         return ret_arr;
44677 }
44678
44679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44680         LDKPaymentParameters this_ptr_conv;
44681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44682         this_ptr_conv.is_owned = false;
44683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44684         LDKCVec_RouteHintZ val_constr;
44685         val_constr.datalen = (*env)->GetArrayLength(env, val);
44686         if (val_constr.datalen > 0)
44687                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
44688         else
44689                 val_constr.data = NULL;
44690         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44691         for (size_t l = 0; l < val_constr.datalen; l++) {
44692                 int64_t val_conv_11 = val_vals[l];
44693                 LDKRouteHint val_conv_11_conv;
44694                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
44695                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
44696                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
44697                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
44698                 val_constr.data[l] = val_conv_11_conv;
44699         }
44700         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44701         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
44702 }
44703
44704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
44705         LDKPaymentParameters this_ptr_conv;
44706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44707         this_ptr_conv.is_owned = false;
44708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44709         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
44710         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
44711         int64_t ret_ref = (uintptr_t)ret_copy;
44712         return ret_ref;
44713 }
44714
44715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44716         LDKPaymentParameters this_ptr_conv;
44717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44718         this_ptr_conv.is_owned = false;
44719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44720         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
44721         CHECK_ACCESS(val_ptr);
44722         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
44723         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
44724         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
44725 }
44726
44727 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
44728         LDKPaymentParameters this_ptr_conv;
44729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44730         this_ptr_conv.is_owned = false;
44731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44732         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
44733         return ret_conv;
44734 }
44735
44736 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) {
44737         LDKPaymentParameters this_ptr_conv;
44738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44739         this_ptr_conv.is_owned = false;
44740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44741         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
44742 }
44743
44744 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1mpp_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
44745         LDKPaymentParameters this_ptr_conv;
44746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44747         this_ptr_conv.is_owned = false;
44748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44749         int8_t ret_conv = PaymentParameters_get_max_mpp_path_count(&this_ptr_conv);
44750         return ret_conv;
44751 }
44752
44753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1mpp_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
44754         LDKPaymentParameters this_ptr_conv;
44755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44756         this_ptr_conv.is_owned = false;
44757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44758         PaymentParameters_set_max_mpp_path_count(&this_ptr_conv, val);
44759 }
44760
44761 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_mpp_path_count_arg) {
44762         LDKPublicKey payee_pubkey_arg_ref;
44763         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
44764         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
44765         LDKInvoiceFeatures features_arg_conv;
44766         features_arg_conv.inner = (void*)(features_arg & (~1));
44767         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
44768         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
44769         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
44770         LDKCVec_RouteHintZ route_hints_arg_constr;
44771         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
44772         if (route_hints_arg_constr.datalen > 0)
44773                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
44774         else
44775                 route_hints_arg_constr.data = NULL;
44776         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
44777         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
44778                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
44779                 LDKRouteHint route_hints_arg_conv_11_conv;
44780                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
44781                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
44782                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
44783                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
44784                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
44785         }
44786         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
44787         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
44788         CHECK_ACCESS(expiry_time_arg_ptr);
44789         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
44790         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
44791         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_mpp_path_count_arg);
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 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
44804         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
44805 int64_t ret_ref = 0;
44806 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44807 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44808 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44809 ret_ref = (uintptr_t)ret_var.inner;
44810 if (ret_var.is_owned) {
44811         ret_ref |= 1;
44812 }
44813         return ret_ref;
44814 }
44815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44816         LDKPaymentParameters arg_conv;
44817         arg_conv.inner = (void*)(arg & (~1));
44818         arg_conv.is_owned = false;
44819         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44820         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
44821         return ret_conv;
44822 }
44823
44824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44825         LDKPaymentParameters orig_conv;
44826         orig_conv.inner = (void*)(orig & (~1));
44827         orig_conv.is_owned = false;
44828         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44829         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
44830         int64_t ret_ref = 0;
44831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44834         ret_ref = (uintptr_t)ret_var.inner;
44835         if (ret_var.is_owned) {
44836                 ret_ref |= 1;
44837         }
44838         return ret_ref;
44839 }
44840
44841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
44842         LDKPaymentParameters o_conv;
44843         o_conv.inner = (void*)(o & (~1));
44844         o_conv.is_owned = false;
44845         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44846         int64_t ret_conv = PaymentParameters_hash(&o_conv);
44847         return ret_conv;
44848 }
44849
44850 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44851         LDKPaymentParameters a_conv;
44852         a_conv.inner = (void*)(a & (~1));
44853         a_conv.is_owned = false;
44854         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44855         LDKPaymentParameters b_conv;
44856         b_conv.inner = (void*)(b & (~1));
44857         b_conv.is_owned = false;
44858         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44859         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
44860         return ret_conv;
44861 }
44862
44863 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
44864         LDKPaymentParameters obj_conv;
44865         obj_conv.inner = (void*)(obj & (~1));
44866         obj_conv.is_owned = false;
44867         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44868         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
44869         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44870         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44871         CVec_u8Z_free(ret_var);
44872         return ret_arr;
44873 }
44874
44875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44876         LDKu8slice ser_ref;
44877         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44878         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44879         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
44880         *ret_conv = PaymentParameters_read(ser_ref);
44881         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44882         return (int64_t)ret_conv;
44883 }
44884
44885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
44886         LDKPublicKey payee_pubkey_ref;
44887         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
44888         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
44889         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
44890         int64_t ret_ref = 0;
44891         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44892         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44894         ret_ref = (uintptr_t)ret_var.inner;
44895         if (ret_var.is_owned) {
44896                 ret_ref |= 1;
44897         }
44898         return ret_ref;
44899 }
44900
44901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
44902         LDKPublicKey payee_pubkey_ref;
44903         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
44904         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
44905         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
44906         int64_t ret_ref = 0;
44907         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44908         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44910         ret_ref = (uintptr_t)ret_var.inner;
44911         if (ret_var.is_owned) {
44912                 ret_ref |= 1;
44913         }
44914         return ret_ref;
44915 }
44916
44917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44918         LDKRouteHint this_obj_conv;
44919         this_obj_conv.inner = (void*)(this_obj & (~1));
44920         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44922         RouteHint_free(this_obj_conv);
44923 }
44924
44925 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44926         LDKRouteHint this_ptr_conv;
44927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44928         this_ptr_conv.is_owned = false;
44929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44930         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
44931         int64_tArray ret_arr = NULL;
44932         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44933         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44934         for (size_t o = 0; o < ret_var.datalen; o++) {
44935                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
44936                 int64_t ret_conv_14_ref = 0;
44937                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44938                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44939                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
44940                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
44941                 if (ret_conv_14_var.is_owned) {
44942                         ret_conv_14_ref |= 1;
44943                 }
44944                 ret_arr_ptr[o] = ret_conv_14_ref;
44945         }
44946         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44947         FREE(ret_var.data);
44948         return ret_arr;
44949 }
44950
44951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44952         LDKRouteHint this_ptr_conv;
44953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44954         this_ptr_conv.is_owned = false;
44955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44956         LDKCVec_RouteHintHopZ val_constr;
44957         val_constr.datalen = (*env)->GetArrayLength(env, val);
44958         if (val_constr.datalen > 0)
44959                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
44960         else
44961                 val_constr.data = NULL;
44962         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44963         for (size_t o = 0; o < val_constr.datalen; o++) {
44964                 int64_t val_conv_14 = val_vals[o];
44965                 LDKRouteHintHop val_conv_14_conv;
44966                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
44967                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
44968                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
44969                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
44970                 val_constr.data[o] = val_conv_14_conv;
44971         }
44972         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44973         RouteHint_set_a(&this_ptr_conv, val_constr);
44974 }
44975
44976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
44977         LDKCVec_RouteHintHopZ a_arg_constr;
44978         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
44979         if (a_arg_constr.datalen > 0)
44980                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
44981         else
44982                 a_arg_constr.data = NULL;
44983         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
44984         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
44985                 int64_t a_arg_conv_14 = a_arg_vals[o];
44986                 LDKRouteHintHop a_arg_conv_14_conv;
44987                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
44988                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
44989                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
44990                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
44991                 a_arg_constr.data[o] = a_arg_conv_14_conv;
44992         }
44993         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
44994         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
44995         int64_t ret_ref = 0;
44996         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44997         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44999         ret_ref = (uintptr_t)ret_var.inner;
45000         if (ret_var.is_owned) {
45001                 ret_ref |= 1;
45002         }
45003         return ret_ref;
45004 }
45005
45006 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
45007         LDKRouteHint ret_var = RouteHint_clone(arg);
45008 int64_t ret_ref = 0;
45009 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45010 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45011 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45012 ret_ref = (uintptr_t)ret_var.inner;
45013 if (ret_var.is_owned) {
45014         ret_ref |= 1;
45015 }
45016         return ret_ref;
45017 }
45018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45019         LDKRouteHint arg_conv;
45020         arg_conv.inner = (void*)(arg & (~1));
45021         arg_conv.is_owned = false;
45022         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45023         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
45024         return ret_conv;
45025 }
45026
45027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45028         LDKRouteHint orig_conv;
45029         orig_conv.inner = (void*)(orig & (~1));
45030         orig_conv.is_owned = false;
45031         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45032         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
45033         int64_t ret_ref = 0;
45034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45037         ret_ref = (uintptr_t)ret_var.inner;
45038         if (ret_var.is_owned) {
45039                 ret_ref |= 1;
45040         }
45041         return ret_ref;
45042 }
45043
45044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
45045         LDKRouteHint o_conv;
45046         o_conv.inner = (void*)(o & (~1));
45047         o_conv.is_owned = false;
45048         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45049         int64_t ret_conv = RouteHint_hash(&o_conv);
45050         return ret_conv;
45051 }
45052
45053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45054         LDKRouteHint a_conv;
45055         a_conv.inner = (void*)(a & (~1));
45056         a_conv.is_owned = false;
45057         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45058         LDKRouteHint b_conv;
45059         b_conv.inner = (void*)(b & (~1));
45060         b_conv.is_owned = false;
45061         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45062         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
45063         return ret_conv;
45064 }
45065
45066 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
45067         LDKRouteHint obj_conv;
45068         obj_conv.inner = (void*)(obj & (~1));
45069         obj_conv.is_owned = false;
45070         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45071         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
45072         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45073         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45074         CVec_u8Z_free(ret_var);
45075         return ret_arr;
45076 }
45077
45078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45079         LDKu8slice ser_ref;
45080         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45081         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45082         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
45083         *ret_conv = RouteHint_read(ser_ref);
45084         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45085         return (int64_t)ret_conv;
45086 }
45087
45088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45089         LDKRouteHintHop this_obj_conv;
45090         this_obj_conv.inner = (void*)(this_obj & (~1));
45091         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45093         RouteHintHop_free(this_obj_conv);
45094 }
45095
45096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
45097         LDKRouteHintHop this_ptr_conv;
45098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45099         this_ptr_conv.is_owned = false;
45100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45101         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45102         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
45103         return ret_arr;
45104 }
45105
45106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45107         LDKRouteHintHop this_ptr_conv;
45108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45109         this_ptr_conv.is_owned = false;
45110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45111         LDKPublicKey val_ref;
45112         CHECK((*env)->GetArrayLength(env, val) == 33);
45113         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
45114         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
45115 }
45116
45117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
45118         LDKRouteHintHop this_ptr_conv;
45119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45120         this_ptr_conv.is_owned = false;
45121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45122         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
45123         return ret_conv;
45124 }
45125
45126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45127         LDKRouteHintHop this_ptr_conv;
45128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45129         this_ptr_conv.is_owned = false;
45130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45131         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
45132 }
45133
45134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
45135         LDKRouteHintHop this_ptr_conv;
45136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45137         this_ptr_conv.is_owned = false;
45138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45139         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_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 void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45152         LDKRouteHintHop this_ptr_conv;
45153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45154         this_ptr_conv.is_owned = false;
45155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45156         LDKRoutingFees val_conv;
45157         val_conv.inner = (void*)(val & (~1));
45158         val_conv.is_owned = (val & 1) || (val == 0);
45159         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45160         val_conv = RoutingFees_clone(&val_conv);
45161         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
45162 }
45163
45164 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45165         LDKRouteHintHop this_ptr_conv;
45166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45167         this_ptr_conv.is_owned = false;
45168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45169         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
45170         return ret_conv;
45171 }
45172
45173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
45174         LDKRouteHintHop this_ptr_conv;
45175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45176         this_ptr_conv.is_owned = false;
45177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45178         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
45179 }
45180
45181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45182         LDKRouteHintHop this_ptr_conv;
45183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45184         this_ptr_conv.is_owned = false;
45185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45186         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45187         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
45188         int64_t ret_ref = (uintptr_t)ret_copy;
45189         return ret_ref;
45190 }
45191
45192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45193         LDKRouteHintHop this_ptr_conv;
45194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45195         this_ptr_conv.is_owned = false;
45196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45197         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
45198         CHECK_ACCESS(val_ptr);
45199         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
45200         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
45201         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
45202 }
45203
45204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45205         LDKRouteHintHop this_ptr_conv;
45206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45207         this_ptr_conv.is_owned = false;
45208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45209         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45210         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
45211         int64_t ret_ref = (uintptr_t)ret_copy;
45212         return ret_ref;
45213 }
45214
45215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45216         LDKRouteHintHop this_ptr_conv;
45217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45218         this_ptr_conv.is_owned = false;
45219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45220         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
45221         CHECK_ACCESS(val_ptr);
45222         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
45223         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
45224         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
45225 }
45226
45227 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) {
45228         LDKPublicKey src_node_id_arg_ref;
45229         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
45230         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
45231         LDKRoutingFees fees_arg_conv;
45232         fees_arg_conv.inner = (void*)(fees_arg & (~1));
45233         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
45234         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
45235         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
45236         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
45237         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
45238         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
45239         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
45240         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
45241         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
45242         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
45243         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
45244         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);
45245         int64_t ret_ref = 0;
45246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45249         ret_ref = (uintptr_t)ret_var.inner;
45250         if (ret_var.is_owned) {
45251                 ret_ref |= 1;
45252         }
45253         return ret_ref;
45254 }
45255
45256 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
45257         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
45258 int64_t ret_ref = 0;
45259 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45260 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45261 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45262 ret_ref = (uintptr_t)ret_var.inner;
45263 if (ret_var.is_owned) {
45264         ret_ref |= 1;
45265 }
45266         return ret_ref;
45267 }
45268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45269         LDKRouteHintHop arg_conv;
45270         arg_conv.inner = (void*)(arg & (~1));
45271         arg_conv.is_owned = false;
45272         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45273         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
45274         return ret_conv;
45275 }
45276
45277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45278         LDKRouteHintHop orig_conv;
45279         orig_conv.inner = (void*)(orig & (~1));
45280         orig_conv.is_owned = false;
45281         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45282         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
45283         int64_t ret_ref = 0;
45284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45287         ret_ref = (uintptr_t)ret_var.inner;
45288         if (ret_var.is_owned) {
45289                 ret_ref |= 1;
45290         }
45291         return ret_ref;
45292 }
45293
45294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
45295         LDKRouteHintHop o_conv;
45296         o_conv.inner = (void*)(o & (~1));
45297         o_conv.is_owned = false;
45298         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45299         int64_t ret_conv = RouteHintHop_hash(&o_conv);
45300         return ret_conv;
45301 }
45302
45303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45304         LDKRouteHintHop a_conv;
45305         a_conv.inner = (void*)(a & (~1));
45306         a_conv.is_owned = false;
45307         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45308         LDKRouteHintHop b_conv;
45309         b_conv.inner = (void*)(b & (~1));
45310         b_conv.is_owned = false;
45311         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45312         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
45313         return ret_conv;
45314 }
45315
45316 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
45317         LDKRouteHintHop obj_conv;
45318         obj_conv.inner = (void*)(obj & (~1));
45319         obj_conv.is_owned = false;
45320         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45321         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
45322         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45323         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45324         CVec_u8Z_free(ret_var);
45325         return ret_arr;
45326 }
45327
45328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45329         LDKu8slice ser_ref;
45330         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45331         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45332         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
45333         *ret_conv = RouteHintHop_read(ser_ref);
45334         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45335         return (int64_t)ret_conv;
45336 }
45337
45338 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) {
45339         LDKPublicKey our_node_pubkey_ref;
45340         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
45341         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
45342         LDKRouteParameters route_params_conv;
45343         route_params_conv.inner = (void*)(route_params & (~1));
45344         route_params_conv.is_owned = false;
45345         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
45346         LDKNetworkGraph network_graph_conv;
45347         network_graph_conv.inner = (void*)(network_graph & (~1));
45348         network_graph_conv.is_owned = false;
45349         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45350         LDKCVec_ChannelDetailsZ first_hops_constr;
45351         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
45352         if (first_hops != NULL) {
45353                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
45354                 if (first_hops_constr.datalen > 0)
45355                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
45356                 else
45357                         first_hops_constr.data = NULL;
45358                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
45359                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
45360                         int64_t first_hops_conv_16 = first_hops_vals[q];
45361                         LDKChannelDetails first_hops_conv_16_conv;
45362                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
45363                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
45364                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
45365                         first_hops_constr.data[q] = first_hops_conv_16_conv;
45366                 }
45367                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
45368                 first_hops_ptr = &first_hops_constr;
45369         }
45370         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45371         CHECK_ACCESS(logger_ptr);
45372         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45373         if (logger_conv.free == LDKLogger_JCalls_free) {
45374                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45375                 LDKLogger_JCalls_cloned(&logger_conv);
45376         }
45377         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
45378         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
45379         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
45380         unsigned char random_seed_bytes_arr[32];
45381         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
45382         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
45383         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
45384         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
45385         *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);
45386         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
45387         return (int64_t)ret_conv;
45388 }
45389
45390 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) {
45391         LDKPublicKey our_node_pubkey_ref;
45392         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
45393         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
45394         LDKCVec_PublicKeyZ hops_constr;
45395         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
45396         if (hops_constr.datalen > 0)
45397                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
45398         else
45399                 hops_constr.data = NULL;
45400         for (size_t i = 0; i < hops_constr.datalen; i++) {
45401                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
45402                 LDKPublicKey hops_conv_8_ref;
45403                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
45404                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
45405                 hops_constr.data[i] = hops_conv_8_ref;
45406         }
45407         LDKRouteParameters route_params_conv;
45408         route_params_conv.inner = (void*)(route_params & (~1));
45409         route_params_conv.is_owned = false;
45410         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
45411         LDKNetworkGraph network_graph_conv;
45412         network_graph_conv.inner = (void*)(network_graph & (~1));
45413         network_graph_conv.is_owned = false;
45414         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45415         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45416         CHECK_ACCESS(logger_ptr);
45417         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45418         if (logger_conv.free == LDKLogger_JCalls_free) {
45419                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45420                 LDKLogger_JCalls_cloned(&logger_conv);
45421         }
45422         unsigned char random_seed_bytes_arr[32];
45423         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
45424         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
45425         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
45426         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
45427         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
45428         return (int64_t)ret_conv;
45429 }
45430
45431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45432         if ((this_ptr & 1) != 0) return;
45433         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45434         CHECK_ACCESS(this_ptr_ptr);
45435         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
45436         FREE((void*)this_ptr);
45437         Score_free(this_ptr_conv);
45438 }
45439
45440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45441         if ((this_ptr & 1) != 0) return;
45442         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45443         CHECK_ACCESS(this_ptr_ptr);
45444         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
45445         FREE((void*)this_ptr);
45446         LockableScore_free(this_ptr_conv);
45447 }
45448
45449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45450         LDKMultiThreadedLockableScore this_obj_conv;
45451         this_obj_conv.inner = (void*)(this_obj & (~1));
45452         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45454         MultiThreadedLockableScore_free(this_obj_conv);
45455 }
45456
45457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
45458         LDKMultiThreadedLockableScore obj_conv;
45459         obj_conv.inner = (void*)(obj & (~1));
45460         obj_conv.is_owned = false;
45461         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45462         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
45463         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45464         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45465         CVec_u8Z_free(ret_var);
45466         return ret_arr;
45467 }
45468
45469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
45470         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
45471         CHECK_ACCESS(score_ptr);
45472         LDKScore score_conv = *(LDKScore*)(score_ptr);
45473         if (score_conv.free == LDKScore_JCalls_free) {
45474                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45475                 LDKScore_JCalls_cloned(&score_conv);
45476         }
45477         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
45478         int64_t ret_ref = 0;
45479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45482         ret_ref = (uintptr_t)ret_var.inner;
45483         if (ret_var.is_owned) {
45484                 ret_ref |= 1;
45485         }
45486         return ret_ref;
45487 }
45488
45489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45490         LDKChannelUsage this_obj_conv;
45491         this_obj_conv.inner = (void*)(this_obj & (~1));
45492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45494         ChannelUsage_free(this_obj_conv);
45495 }
45496
45497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45498         LDKChannelUsage this_ptr_conv;
45499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45500         this_ptr_conv.is_owned = false;
45501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45502         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
45503         return ret_conv;
45504 }
45505
45506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45507         LDKChannelUsage this_ptr_conv;
45508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45509         this_ptr_conv.is_owned = false;
45510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45511         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
45512 }
45513
45514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45515         LDKChannelUsage this_ptr_conv;
45516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45517         this_ptr_conv.is_owned = false;
45518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45519         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
45520         return ret_conv;
45521 }
45522
45523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45524         LDKChannelUsage this_ptr_conv;
45525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45526         this_ptr_conv.is_owned = false;
45527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45528         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
45529 }
45530
45531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
45532         LDKChannelUsage this_ptr_conv;
45533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45534         this_ptr_conv.is_owned = false;
45535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45536         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
45537         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
45538         int64_t ret_ref = (uintptr_t)ret_copy;
45539         return ret_ref;
45540 }
45541
45542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45543         LDKChannelUsage this_ptr_conv;
45544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45545         this_ptr_conv.is_owned = false;
45546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45547         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
45548         CHECK_ACCESS(val_ptr);
45549         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
45550         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
45551         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
45552 }
45553
45554 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) {
45555         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
45556         CHECK_ACCESS(effective_capacity_arg_ptr);
45557         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
45558         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
45559         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
45560         int64_t ret_ref = 0;
45561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45564         ret_ref = (uintptr_t)ret_var.inner;
45565         if (ret_var.is_owned) {
45566                 ret_ref |= 1;
45567         }
45568         return ret_ref;
45569 }
45570
45571 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
45572         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
45573 int64_t ret_ref = 0;
45574 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45575 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45576 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45577 ret_ref = (uintptr_t)ret_var.inner;
45578 if (ret_var.is_owned) {
45579         ret_ref |= 1;
45580 }
45581         return ret_ref;
45582 }
45583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45584         LDKChannelUsage arg_conv;
45585         arg_conv.inner = (void*)(arg & (~1));
45586         arg_conv.is_owned = false;
45587         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45588         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
45589         return ret_conv;
45590 }
45591
45592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45593         LDKChannelUsage orig_conv;
45594         orig_conv.inner = (void*)(orig & (~1));
45595         orig_conv.is_owned = false;
45596         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45597         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
45598         int64_t ret_ref = 0;
45599         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45600         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45602         ret_ref = (uintptr_t)ret_var.inner;
45603         if (ret_var.is_owned) {
45604                 ret_ref |= 1;
45605         }
45606         return ret_ref;
45607 }
45608
45609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45610         LDKFixedPenaltyScorer this_obj_conv;
45611         this_obj_conv.inner = (void*)(this_obj & (~1));
45612         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45614         FixedPenaltyScorer_free(this_obj_conv);
45615 }
45616
45617 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
45618         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
45619 int64_t ret_ref = 0;
45620 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45621 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45622 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45623 ret_ref = (uintptr_t)ret_var.inner;
45624 if (ret_var.is_owned) {
45625         ret_ref |= 1;
45626 }
45627         return ret_ref;
45628 }
45629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45630         LDKFixedPenaltyScorer arg_conv;
45631         arg_conv.inner = (void*)(arg & (~1));
45632         arg_conv.is_owned = false;
45633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45634         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
45635         return ret_conv;
45636 }
45637
45638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45639         LDKFixedPenaltyScorer orig_conv;
45640         orig_conv.inner = (void*)(orig & (~1));
45641         orig_conv.is_owned = false;
45642         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45643         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
45644         int64_t ret_ref = 0;
45645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45648         ret_ref = (uintptr_t)ret_var.inner;
45649         if (ret_var.is_owned) {
45650                 ret_ref |= 1;
45651         }
45652         return ret_ref;
45653 }
45654
45655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
45656         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
45657         int64_t ret_ref = 0;
45658         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45659         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45661         ret_ref = (uintptr_t)ret_var.inner;
45662         if (ret_var.is_owned) {
45663                 ret_ref |= 1;
45664         }
45665         return ret_ref;
45666 }
45667
45668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
45669         LDKFixedPenaltyScorer this_arg_conv;
45670         this_arg_conv.inner = (void*)(this_arg & (~1));
45671         this_arg_conv.is_owned = false;
45672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45673         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
45674         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
45675         return (int64_t)ret_ret;
45676 }
45677
45678 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
45679         LDKFixedPenaltyScorer obj_conv;
45680         obj_conv.inner = (void*)(obj & (~1));
45681         obj_conv.is_owned = false;
45682         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45683         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
45684         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45685         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45686         CVec_u8Z_free(ret_var);
45687         return ret_arr;
45688 }
45689
45690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
45691         LDKu8slice ser_ref;
45692         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45693         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45694         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
45695         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
45696         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45697         return (int64_t)ret_conv;
45698 }
45699
45700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45701         LDKProbabilisticScorer this_obj_conv;
45702         this_obj_conv.inner = (void*)(this_obj & (~1));
45703         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45705         ProbabilisticScorer_free(this_obj_conv);
45706 }
45707
45708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45709         LDKProbabilisticScoringParameters this_obj_conv;
45710         this_obj_conv.inner = (void*)(this_obj & (~1));
45711         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45713         ProbabilisticScoringParameters_free(this_obj_conv);
45714 }
45715
45716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45717         LDKProbabilisticScoringParameters this_ptr_conv;
45718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45719         this_ptr_conv.is_owned = false;
45720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45721         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
45722         return ret_conv;
45723 }
45724
45725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45726         LDKProbabilisticScoringParameters this_ptr_conv;
45727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45728         this_ptr_conv.is_owned = false;
45729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45730         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
45731 }
45732
45733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45734         LDKProbabilisticScoringParameters this_ptr_conv;
45735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45736         this_ptr_conv.is_owned = false;
45737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45738         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
45739         return ret_conv;
45740 }
45741
45742 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) {
45743         LDKProbabilisticScoringParameters this_ptr_conv;
45744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45745         this_ptr_conv.is_owned = false;
45746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45747         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
45748 }
45749
45750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
45751         LDKProbabilisticScoringParameters this_ptr_conv;
45752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45753         this_ptr_conv.is_owned = false;
45754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45755         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
45756         return ret_conv;
45757 }
45758
45759 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) {
45760         LDKProbabilisticScoringParameters this_ptr_conv;
45761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45762         this_ptr_conv.is_owned = false;
45763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45764         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
45765 }
45766
45767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1amount_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45768         LDKProbabilisticScoringParameters this_ptr_conv;
45769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45770         this_ptr_conv.is_owned = false;
45771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45772         int64_t ret_conv = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
45773         return ret_conv;
45774 }
45775
45776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1amount_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45777         LDKProbabilisticScoringParameters this_ptr_conv;
45778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45779         this_ptr_conv.is_owned = false;
45780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45781         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
45782 }
45783
45784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45785         LDKProbabilisticScoringParameters this_ptr_conv;
45786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45787         this_ptr_conv.is_owned = false;
45788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45789         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
45790         return ret_conv;
45791 }
45792
45793 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) {
45794         LDKProbabilisticScoringParameters this_ptr_conv;
45795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45796         this_ptr_conv.is_owned = false;
45797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45798         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
45799 }
45800
45801 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
45802         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
45803 int64_t ret_ref = 0;
45804 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45805 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45806 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45807 ret_ref = (uintptr_t)ret_var.inner;
45808 if (ret_var.is_owned) {
45809         ret_ref |= 1;
45810 }
45811         return ret_ref;
45812 }
45813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45814         LDKProbabilisticScoringParameters arg_conv;
45815         arg_conv.inner = (void*)(arg & (~1));
45816         arg_conv.is_owned = false;
45817         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45818         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
45819         return ret_conv;
45820 }
45821
45822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45823         LDKProbabilisticScoringParameters orig_conv;
45824         orig_conv.inner = (void*)(orig & (~1));
45825         orig_conv.is_owned = false;
45826         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45827         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
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
45839 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) {
45840         LDKProbabilisticScoringParameters params_conv;
45841         params_conv.inner = (void*)(params & (~1));
45842         params_conv.is_owned = (params & 1) || (params == 0);
45843         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
45844         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
45845         LDKNetworkGraph network_graph_conv;
45846         network_graph_conv.inner = (void*)(network_graph & (~1));
45847         network_graph_conv.is_owned = false;
45848         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
45849         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45850         CHECK_ACCESS(logger_ptr);
45851         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45852         if (logger_conv.free == LDKLogger_JCalls_free) {
45853                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45854                 LDKLogger_JCalls_cloned(&logger_conv);
45855         }
45856         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
45857         int64_t ret_ref = 0;
45858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45861         ret_ref = (uintptr_t)ret_var.inner;
45862         if (ret_var.is_owned) {
45863                 ret_ref |= 1;
45864         }
45865         return ret_ref;
45866 }
45867
45868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
45869         LDKProbabilisticScorer this_arg_conv;
45870         this_arg_conv.inner = (void*)(this_arg & (~1));
45871         this_arg_conv.is_owned = false;
45872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45873         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
45874 }
45875
45876 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) {
45877         LDKProbabilisticScorer this_arg_conv;
45878         this_arg_conv.inner = (void*)(this_arg & (~1));
45879         this_arg_conv.is_owned = false;
45880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45881         LDKNodeId target_conv;
45882         target_conv.inner = (void*)(target & (~1));
45883         target_conv.is_owned = false;
45884         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
45885         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
45886         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
45887         int64_t ret_ref = (uintptr_t)ret_copy;
45888         return ret_ref;
45889 }
45890
45891 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
45892         LDKProbabilisticScorer this_arg_conv;
45893         this_arg_conv.inner = (void*)(this_arg & (~1));
45894         this_arg_conv.is_owned = false;
45895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45896         LDKNodeId node_id_conv;
45897         node_id_conv.inner = (void*)(node_id & (~1));
45898         node_id_conv.is_owned = false;
45899         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
45900         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
45901 }
45902
45903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
45904         LDKProbabilisticScorer this_arg_conv;
45905         this_arg_conv.inner = (void*)(this_arg & (~1));
45906         this_arg_conv.is_owned = false;
45907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45908         LDKNodeId node_id_conv;
45909         node_id_conv.inner = (void*)(node_id & (~1));
45910         node_id_conv.is_owned = false;
45911         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
45912         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
45913 }
45914
45915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1banned(JNIEnv *env, jclass clz, int64_t this_arg) {
45916         LDKProbabilisticScorer this_arg_conv;
45917         this_arg_conv.inner = (void*)(this_arg & (~1));
45918         this_arg_conv.is_owned = false;
45919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45920         ProbabilisticScorer_clear_banned(&this_arg_conv);
45921 }
45922
45923 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) {
45924         LDKProbabilisticScoringParameters this_arg_conv;
45925         this_arg_conv.inner = (void*)(this_arg & (~1));
45926         this_arg_conv.is_owned = false;
45927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45928         LDKCVec_NodeIdZ node_ids_constr;
45929         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
45930         if (node_ids_constr.datalen > 0)
45931                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
45932         else
45933                 node_ids_constr.data = NULL;
45934         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
45935         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
45936                 int64_t node_ids_conv_8 = node_ids_vals[i];
45937                 LDKNodeId node_ids_conv_8_conv;
45938                 node_ids_conv_8_conv.inner = (void*)(node_ids_conv_8 & (~1));
45939                 node_ids_conv_8_conv.is_owned = (node_ids_conv_8 & 1) || (node_ids_conv_8 == 0);
45940                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
45941                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
45942                 node_ids_constr.data[i] = node_ids_conv_8_conv;
45943         }
45944         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
45945         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
45946 }
45947
45948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
45949         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
45950         int64_t ret_ref = 0;
45951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45954         ret_ref = (uintptr_t)ret_var.inner;
45955         if (ret_var.is_owned) {
45956                 ret_ref |= 1;
45957         }
45958         return ret_ref;
45959 }
45960
45961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
45962         LDKProbabilisticScorer this_arg_conv;
45963         this_arg_conv.inner = (void*)(this_arg & (~1));
45964         this_arg_conv.is_owned = false;
45965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45966         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
45967         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
45968         return (int64_t)ret_ret;
45969 }
45970
45971 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
45972         LDKProbabilisticScorer obj_conv;
45973         obj_conv.inner = (void*)(obj & (~1));
45974         obj_conv.is_owned = false;
45975         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45976         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
45977         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45978         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45979         CVec_u8Z_free(ret_var);
45980         return ret_arr;
45981 }
45982
45983 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) {
45984         LDKu8slice ser_ref;
45985         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45986         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45987         LDKProbabilisticScoringParameters arg_a_conv;
45988         arg_a_conv.inner = (void*)(arg_a & (~1));
45989         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
45990         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
45991         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
45992         LDKNetworkGraph arg_b_conv;
45993         arg_b_conv.inner = (void*)(arg_b & (~1));
45994         arg_b_conv.is_owned = false;
45995         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
45996         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
45997         CHECK_ACCESS(arg_c_ptr);
45998         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
45999         if (arg_c_conv.free == LDKLogger_JCalls_free) {
46000                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46001                 LDKLogger_JCalls_cloned(&arg_c_conv);
46002         }
46003         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
46004         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
46005         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46006         return (int64_t)ret_conv;
46007 }
46008
46009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46010         LDKFilesystemPersister this_obj_conv;
46011         this_obj_conv.inner = (void*)(this_obj & (~1));
46012         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46014         FilesystemPersister_free(this_obj_conv);
46015 }
46016
46017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
46018         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
46019         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
46020         int64_t ret_ref = 0;
46021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46024         ret_ref = (uintptr_t)ret_var.inner;
46025         if (ret_var.is_owned) {
46026                 ret_ref |= 1;
46027         }
46028         return ret_ref;
46029 }
46030
46031 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
46032         LDKFilesystemPersister this_arg_conv;
46033         this_arg_conv.inner = (void*)(this_arg & (~1));
46034         this_arg_conv.is_owned = false;
46035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46036         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
46037         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46038         Str_free(ret_str);
46039         return ret_conv;
46040 }
46041
46042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
46043         LDKFilesystemPersister this_arg_conv;
46044         this_arg_conv.inner = (void*)(this_arg & (~1));
46045         this_arg_conv.is_owned = false;
46046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46047         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46048         CHECK_ACCESS(keys_manager_ptr);
46049         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46050         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46051                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46052                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46053         }
46054         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
46055         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
46056         return (int64_t)ret_conv;
46057 }
46058
46059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46060         LDKBackgroundProcessor this_obj_conv;
46061         this_obj_conv.inner = (void*)(this_obj & (~1));
46062         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46064         BackgroundProcessor_free(this_obj_conv);
46065 }
46066
46067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46068         if ((this_ptr & 1) != 0) return;
46069         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46070         CHECK_ACCESS(this_ptr_ptr);
46071         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
46072         FREE((void*)this_ptr);
46073         GossipSync_free(this_ptr_conv);
46074 }
46075
46076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
46077         LDKP2PGossipSync a_conv;
46078         a_conv.inner = (void*)(a & (~1));
46079         a_conv.is_owned = false;
46080         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46081         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46082         *ret_copy = GossipSync_p2_p(&a_conv);
46083         int64_t ret_ref = (uintptr_t)ret_copy;
46084         return ret_ref;
46085 }
46086
46087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
46088         LDKRapidGossipSync a_conv;
46089         a_conv.inner = (void*)(a & (~1));
46090         a_conv.is_owned = false;
46091         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46092         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46093         *ret_copy = GossipSync_rapid(&a_conv);
46094         int64_t ret_ref = (uintptr_t)ret_copy;
46095         return ret_ref;
46096 }
46097
46098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
46099         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
46100         *ret_copy = GossipSync_none();
46101         int64_t ret_ref = (uintptr_t)ret_copy;
46102         return ret_ref;
46103 }
46104
46105 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) {
46106         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
46107         CHECK_ACCESS(persister_ptr);
46108         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
46109         if (persister_conv.free == LDKPersister_JCalls_free) {
46110                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46111                 LDKPersister_JCalls_cloned(&persister_conv);
46112         }
46113         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
46114         CHECK_ACCESS(event_handler_ptr);
46115         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
46116         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
46117                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46118                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
46119         }
46120         LDKChainMonitor chain_monitor_conv;
46121         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
46122         chain_monitor_conv.is_owned = false;
46123         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
46124         LDKChannelManager channel_manager_conv;
46125         channel_manager_conv.inner = (void*)(channel_manager & (~1));
46126         channel_manager_conv.is_owned = false;
46127         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
46128         void* gossip_sync_ptr = (void*)(((uintptr_t)gossip_sync) & ~1);
46129         CHECK_ACCESS(gossip_sync_ptr);
46130         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
46131         // WARNING: we may need a move here but no clone is available for LDKGossipSync
46132         LDKPeerManager peer_manager_conv;
46133         peer_manager_conv.inner = (void*)(peer_manager & (~1));
46134         peer_manager_conv.is_owned = false;
46135         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
46136         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46137         CHECK_ACCESS(logger_ptr);
46138         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46139         if (logger_conv.free == LDKLogger_JCalls_free) {
46140                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46141                 LDKLogger_JCalls_cloned(&logger_conv);
46142         }
46143         LDKMultiThreadedLockableScore scorer_conv;
46144         scorer_conv.inner = (void*)(scorer & (~1));
46145         scorer_conv.is_owned = (scorer & 1) || (scorer == 0);
46146         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
46147         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);
46148         int64_t ret_ref = 0;
46149         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46150         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46152         ret_ref = (uintptr_t)ret_var.inner;
46153         if (ret_var.is_owned) {
46154                 ret_ref |= 1;
46155         }
46156         return ret_ref;
46157 }
46158
46159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
46160         LDKBackgroundProcessor this_arg_conv;
46161         this_arg_conv.inner = (void*)(this_arg & (~1));
46162         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
46163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46164         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
46165         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
46166         *ret_conv = BackgroundProcessor_join(this_arg_conv);
46167         return (int64_t)ret_conv;
46168 }
46169
46170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
46171         LDKBackgroundProcessor this_arg_conv;
46172         this_arg_conv.inner = (void*)(this_arg & (~1));
46173         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
46174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46175         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
46176         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
46177         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
46178         return (int64_t)ret_conv;
46179 }
46180
46181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46182         if ((this_ptr & 1) != 0) return;
46183         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46184         CHECK_ACCESS(this_ptr_ptr);
46185         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
46186         FREE((void*)this_ptr);
46187         ParseError_free(this_ptr_conv);
46188 }
46189
46190 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
46191         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46192         *ret_copy = ParseError_clone(arg);
46193 int64_t ret_ref = (uintptr_t)ret_copy;
46194         return ret_ref;
46195 }
46196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46197         LDKParseError* arg_conv = (LDKParseError*)arg;
46198         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
46199         return ret_conv;
46200 }
46201
46202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46203         LDKParseError* orig_conv = (LDKParseError*)orig;
46204         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46205         *ret_copy = ParseError_clone(orig_conv);
46206         int64_t ret_ref = (uintptr_t)ret_copy;
46207         return ret_ref;
46208 }
46209
46210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
46211         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
46212         CHECK_ACCESS(a_ptr);
46213         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
46214         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
46215         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46216         *ret_copy = ParseError_bech32_error(a_conv);
46217         int64_t ret_ref = (uintptr_t)ret_copy;
46218         return ret_ref;
46219 }
46220
46221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
46222         
46223         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46224         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
46225         int64_t ret_ref = (uintptr_t)ret_copy;
46226         return ret_ref;
46227 }
46228
46229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
46230         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
46231         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46232         *ret_copy = ParseError_malformed_signature(a_conv);
46233         int64_t ret_ref = (uintptr_t)ret_copy;
46234         return ret_ref;
46235 }
46236
46237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
46238         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46239         *ret_copy = ParseError_bad_prefix();
46240         int64_t ret_ref = (uintptr_t)ret_copy;
46241         return ret_ref;
46242 }
46243
46244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
46245         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46246         *ret_copy = ParseError_unknown_currency();
46247         int64_t ret_ref = (uintptr_t)ret_copy;
46248         return ret_ref;
46249 }
46250
46251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
46252         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46253         *ret_copy = ParseError_unknown_si_prefix();
46254         int64_t ret_ref = (uintptr_t)ret_copy;
46255         return ret_ref;
46256 }
46257
46258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
46259         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46260         *ret_copy = ParseError_malformed_hrp();
46261         int64_t ret_ref = (uintptr_t)ret_copy;
46262         return ret_ref;
46263 }
46264
46265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
46266         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46267         *ret_copy = ParseError_too_short_data_part();
46268         int64_t ret_ref = (uintptr_t)ret_copy;
46269         return ret_ref;
46270 }
46271
46272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
46273         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46274         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
46275         int64_t ret_ref = (uintptr_t)ret_copy;
46276         return ret_ref;
46277 }
46278
46279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
46280         
46281         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46282         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
46283         int64_t ret_ref = (uintptr_t)ret_copy;
46284         return ret_ref;
46285 }
46286
46287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
46288         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46289         *ret_copy = ParseError_padding_error();
46290         int64_t ret_ref = (uintptr_t)ret_copy;
46291         return ret_ref;
46292 }
46293
46294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
46295         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46296         *ret_copy = ParseError_integer_overflow_error();
46297         int64_t ret_ref = (uintptr_t)ret_copy;
46298         return ret_ref;
46299 }
46300
46301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
46302         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46303         *ret_copy = ParseError_invalid_seg_wit_program_length();
46304         int64_t ret_ref = (uintptr_t)ret_copy;
46305         return ret_ref;
46306 }
46307
46308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
46309         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46310         *ret_copy = ParseError_invalid_pub_key_hash_length();
46311         int64_t ret_ref = (uintptr_t)ret_copy;
46312         return ret_ref;
46313 }
46314
46315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
46316         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46317         *ret_copy = ParseError_invalid_script_hash_length();
46318         int64_t ret_ref = (uintptr_t)ret_copy;
46319         return ret_ref;
46320 }
46321
46322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
46323         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46324         *ret_copy = ParseError_invalid_recovery_id();
46325         int64_t ret_ref = (uintptr_t)ret_copy;
46326         return ret_ref;
46327 }
46328
46329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
46330         LDKStr a_conv = java_to_owned_str(env, a);
46331         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46332         *ret_copy = ParseError_invalid_slice_length(a_conv);
46333         int64_t ret_ref = (uintptr_t)ret_copy;
46334         return ret_ref;
46335 }
46336
46337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
46338         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
46339         *ret_copy = ParseError_skip();
46340         int64_t ret_ref = (uintptr_t)ret_copy;
46341         return ret_ref;
46342 }
46343
46344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46345         if ((this_ptr & 1) != 0) return;
46346         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
46347         CHECK_ACCESS(this_ptr_ptr);
46348         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
46349         FREE((void*)this_ptr);
46350         ParseOrSemanticError_free(this_ptr_conv);
46351 }
46352
46353 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
46354         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
46355         *ret_copy = ParseOrSemanticError_clone(arg);
46356 int64_t ret_ref = (uintptr_t)ret_copy;
46357         return ret_ref;
46358 }
46359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46360         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
46361         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
46362         return ret_conv;
46363 }
46364
46365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46366         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
46367         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
46368         *ret_copy = ParseOrSemanticError_clone(orig_conv);
46369         int64_t ret_ref = (uintptr_t)ret_copy;
46370         return ret_ref;
46371 }
46372
46373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
46374         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
46375         CHECK_ACCESS(a_ptr);
46376         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
46377         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
46378         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
46379         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
46380         int64_t ret_ref = (uintptr_t)ret_copy;
46381         return ret_ref;
46382 }
46383
46384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
46385         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
46386         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
46387         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
46388         int64_t ret_ref = (uintptr_t)ret_copy;
46389         return ret_ref;
46390 }
46391
46392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46393         LDKInvoice this_obj_conv;
46394         this_obj_conv.inner = (void*)(this_obj & (~1));
46395         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46397         Invoice_free(this_obj_conv);
46398 }
46399
46400 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46401         LDKInvoice a_conv;
46402         a_conv.inner = (void*)(a & (~1));
46403         a_conv.is_owned = false;
46404         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46405         LDKInvoice b_conv;
46406         b_conv.inner = (void*)(b & (~1));
46407         b_conv.is_owned = false;
46408         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46409         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
46410         return ret_conv;
46411 }
46412
46413 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
46414         LDKInvoice ret_var = Invoice_clone(arg);
46415 int64_t ret_ref = 0;
46416 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46417 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46418 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46419 ret_ref = (uintptr_t)ret_var.inner;
46420 if (ret_var.is_owned) {
46421         ret_ref |= 1;
46422 }
46423         return ret_ref;
46424 }
46425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46426         LDKInvoice arg_conv;
46427         arg_conv.inner = (void*)(arg & (~1));
46428         arg_conv.is_owned = false;
46429         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46430         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
46431         return ret_conv;
46432 }
46433
46434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46435         LDKInvoice orig_conv;
46436         orig_conv.inner = (void*)(orig & (~1));
46437         orig_conv.is_owned = false;
46438         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46439         LDKInvoice ret_var = Invoice_clone(&orig_conv);
46440         int64_t ret_ref = 0;
46441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46444         ret_ref = (uintptr_t)ret_var.inner;
46445         if (ret_var.is_owned) {
46446                 ret_ref |= 1;
46447         }
46448         return ret_ref;
46449 }
46450
46451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46452         LDKSignedRawInvoice this_obj_conv;
46453         this_obj_conv.inner = (void*)(this_obj & (~1));
46454         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46456         SignedRawInvoice_free(this_obj_conv);
46457 }
46458
46459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46460         LDKSignedRawInvoice a_conv;
46461         a_conv.inner = (void*)(a & (~1));
46462         a_conv.is_owned = false;
46463         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46464         LDKSignedRawInvoice b_conv;
46465         b_conv.inner = (void*)(b & (~1));
46466         b_conv.is_owned = false;
46467         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46468         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
46469         return ret_conv;
46470 }
46471
46472 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
46473         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
46474 int64_t ret_ref = 0;
46475 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46476 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46477 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46478 ret_ref = (uintptr_t)ret_var.inner;
46479 if (ret_var.is_owned) {
46480         ret_ref |= 1;
46481 }
46482         return ret_ref;
46483 }
46484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46485         LDKSignedRawInvoice arg_conv;
46486         arg_conv.inner = (void*)(arg & (~1));
46487         arg_conv.is_owned = false;
46488         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46489         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
46490         return ret_conv;
46491 }
46492
46493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46494         LDKSignedRawInvoice orig_conv;
46495         orig_conv.inner = (void*)(orig & (~1));
46496         orig_conv.is_owned = false;
46497         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46498         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
46499         int64_t ret_ref = 0;
46500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46503         ret_ref = (uintptr_t)ret_var.inner;
46504         if (ret_var.is_owned) {
46505                 ret_ref |= 1;
46506         }
46507         return ret_ref;
46508 }
46509
46510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46511         LDKRawInvoice this_obj_conv;
46512         this_obj_conv.inner = (void*)(this_obj & (~1));
46513         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46515         RawInvoice_free(this_obj_conv);
46516 }
46517
46518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
46519         LDKRawInvoice this_ptr_conv;
46520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46521         this_ptr_conv.is_owned = false;
46522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46523         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
46524         int64_t ret_ref = 0;
46525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46528         ret_ref = (uintptr_t)ret_var.inner;
46529         if (ret_var.is_owned) {
46530                 ret_ref |= 1;
46531         }
46532         return ret_ref;
46533 }
46534
46535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46536         LDKRawInvoice this_ptr_conv;
46537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46538         this_ptr_conv.is_owned = false;
46539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46540         LDKRawDataPart val_conv;
46541         val_conv.inner = (void*)(val & (~1));
46542         val_conv.is_owned = (val & 1) || (val == 0);
46543         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46544         val_conv = RawDataPart_clone(&val_conv);
46545         RawInvoice_set_data(&this_ptr_conv, val_conv);
46546 }
46547
46548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46549         LDKRawInvoice a_conv;
46550         a_conv.inner = (void*)(a & (~1));
46551         a_conv.is_owned = false;
46552         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46553         LDKRawInvoice b_conv;
46554         b_conv.inner = (void*)(b & (~1));
46555         b_conv.is_owned = false;
46556         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46557         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
46558         return ret_conv;
46559 }
46560
46561 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
46562         LDKRawInvoice ret_var = RawInvoice_clone(arg);
46563 int64_t ret_ref = 0;
46564 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46565 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46566 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46567 ret_ref = (uintptr_t)ret_var.inner;
46568 if (ret_var.is_owned) {
46569         ret_ref |= 1;
46570 }
46571         return ret_ref;
46572 }
46573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46574         LDKRawInvoice arg_conv;
46575         arg_conv.inner = (void*)(arg & (~1));
46576         arg_conv.is_owned = false;
46577         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46578         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
46579         return ret_conv;
46580 }
46581
46582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46583         LDKRawInvoice orig_conv;
46584         orig_conv.inner = (void*)(orig & (~1));
46585         orig_conv.is_owned = false;
46586         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46587         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
46588         int64_t ret_ref = 0;
46589         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46590         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46592         ret_ref = (uintptr_t)ret_var.inner;
46593         if (ret_var.is_owned) {
46594                 ret_ref |= 1;
46595         }
46596         return ret_ref;
46597 }
46598
46599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46600         LDKRawDataPart this_obj_conv;
46601         this_obj_conv.inner = (void*)(this_obj & (~1));
46602         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46604         RawDataPart_free(this_obj_conv);
46605 }
46606
46607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
46608         LDKRawDataPart this_ptr_conv;
46609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46610         this_ptr_conv.is_owned = false;
46611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46612         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
46613         int64_t ret_ref = 0;
46614         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46615         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46617         ret_ref = (uintptr_t)ret_var.inner;
46618         if (ret_var.is_owned) {
46619                 ret_ref |= 1;
46620         }
46621         return ret_ref;
46622 }
46623
46624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46625         LDKRawDataPart this_ptr_conv;
46626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46627         this_ptr_conv.is_owned = false;
46628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46629         LDKPositiveTimestamp val_conv;
46630         val_conv.inner = (void*)(val & (~1));
46631         val_conv.is_owned = (val & 1) || (val == 0);
46632         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46633         val_conv = PositiveTimestamp_clone(&val_conv);
46634         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
46635 }
46636
46637 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46638         LDKRawDataPart a_conv;
46639         a_conv.inner = (void*)(a & (~1));
46640         a_conv.is_owned = false;
46641         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46642         LDKRawDataPart b_conv;
46643         b_conv.inner = (void*)(b & (~1));
46644         b_conv.is_owned = false;
46645         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46646         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
46647         return ret_conv;
46648 }
46649
46650 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
46651         LDKRawDataPart ret_var = RawDataPart_clone(arg);
46652 int64_t ret_ref = 0;
46653 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46654 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46655 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46656 ret_ref = (uintptr_t)ret_var.inner;
46657 if (ret_var.is_owned) {
46658         ret_ref |= 1;
46659 }
46660         return ret_ref;
46661 }
46662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46663         LDKRawDataPart arg_conv;
46664         arg_conv.inner = (void*)(arg & (~1));
46665         arg_conv.is_owned = false;
46666         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46667         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
46668         return ret_conv;
46669 }
46670
46671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46672         LDKRawDataPart orig_conv;
46673         orig_conv.inner = (void*)(orig & (~1));
46674         orig_conv.is_owned = false;
46675         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46676         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
46677         int64_t ret_ref = 0;
46678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46681         ret_ref = (uintptr_t)ret_var.inner;
46682         if (ret_var.is_owned) {
46683                 ret_ref |= 1;
46684         }
46685         return ret_ref;
46686 }
46687
46688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46689         LDKPositiveTimestamp this_obj_conv;
46690         this_obj_conv.inner = (void*)(this_obj & (~1));
46691         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46693         PositiveTimestamp_free(this_obj_conv);
46694 }
46695
46696 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46697         LDKPositiveTimestamp a_conv;
46698         a_conv.inner = (void*)(a & (~1));
46699         a_conv.is_owned = false;
46700         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46701         LDKPositiveTimestamp b_conv;
46702         b_conv.inner = (void*)(b & (~1));
46703         b_conv.is_owned = false;
46704         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46705         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
46706         return ret_conv;
46707 }
46708
46709 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
46710         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46722         LDKPositiveTimestamp arg_conv;
46723         arg_conv.inner = (void*)(arg & (~1));
46724         arg_conv.is_owned = false;
46725         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46726         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
46727         return ret_conv;
46728 }
46729
46730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46731         LDKPositiveTimestamp orig_conv;
46732         orig_conv.inner = (void*)(orig & (~1));
46733         orig_conv.is_owned = false;
46734         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46735         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
46736         int64_t ret_ref = 0;
46737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46740         ret_ref = (uintptr_t)ret_var.inner;
46741         if (ret_var.is_owned) {
46742                 ret_ref |= 1;
46743         }
46744         return ret_ref;
46745 }
46746
46747 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46748         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
46749         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
46750         return ret_conv;
46751 }
46752
46753 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
46754         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
46755         return ret_conv;
46756 }
46757
46758 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
46759         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
46760         return ret_conv;
46761 }
46762
46763 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
46764         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
46765         return ret_conv;
46766 }
46767
46768 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
46769         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
46770         return ret_conv;
46771 }
46772
46773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46774         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
46775         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
46776         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
46777         return ret_conv;
46778 }
46779
46780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
46781         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
46782         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
46783         return ret_conv;
46784 }
46785
46786 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46787         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
46788         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
46789         return ret_conv;
46790 }
46791
46792 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
46793         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
46794         return ret_conv;
46795 }
46796
46797 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
46798         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
46799         return ret_conv;
46800 }
46801
46802 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
46803         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
46804         return ret_conv;
46805 }
46806
46807 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
46808         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
46809         return ret_conv;
46810 }
46811
46812 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
46813         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
46814         return ret_conv;
46815 }
46816
46817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
46818         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
46819         int64_t ret_conv = Currency_hash(o_conv);
46820         return ret_conv;
46821 }
46822
46823 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46824         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
46825         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
46826         jboolean ret_conv = Currency_eq(a_conv, b_conv);
46827         return ret_conv;
46828 }
46829
46830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46831         LDKSha256 this_obj_conv;
46832         this_obj_conv.inner = (void*)(this_obj & (~1));
46833         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46835         Sha256_free(this_obj_conv);
46836 }
46837
46838 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
46839         LDKSha256 ret_var = Sha256_clone(arg);
46840 int64_t ret_ref = 0;
46841 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46842 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46843 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46844 ret_ref = (uintptr_t)ret_var.inner;
46845 if (ret_var.is_owned) {
46846         ret_ref |= 1;
46847 }
46848         return ret_ref;
46849 }
46850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46851         LDKSha256 arg_conv;
46852         arg_conv.inner = (void*)(arg & (~1));
46853         arg_conv.is_owned = false;
46854         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46855         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
46856         return ret_conv;
46857 }
46858
46859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46860         LDKSha256 orig_conv;
46861         orig_conv.inner = (void*)(orig & (~1));
46862         orig_conv.is_owned = false;
46863         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46864         LDKSha256 ret_var = Sha256_clone(&orig_conv);
46865         int64_t ret_ref = 0;
46866         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46867         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46869         ret_ref = (uintptr_t)ret_var.inner;
46870         if (ret_var.is_owned) {
46871                 ret_ref |= 1;
46872         }
46873         return ret_ref;
46874 }
46875
46876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
46877         LDKSha256 o_conv;
46878         o_conv.inner = (void*)(o & (~1));
46879         o_conv.is_owned = false;
46880         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46881         int64_t ret_conv = Sha256_hash(&o_conv);
46882         return ret_conv;
46883 }
46884
46885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46886         LDKSha256 a_conv;
46887         a_conv.inner = (void*)(a & (~1));
46888         a_conv.is_owned = false;
46889         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46890         LDKSha256 b_conv;
46891         b_conv.inner = (void*)(b & (~1));
46892         b_conv.is_owned = false;
46893         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46894         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
46895         return ret_conv;
46896 }
46897
46898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46899         LDKDescription this_obj_conv;
46900         this_obj_conv.inner = (void*)(this_obj & (~1));
46901         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46903         Description_free(this_obj_conv);
46904 }
46905
46906 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
46907         LDKDescription ret_var = Description_clone(arg);
46908 int64_t ret_ref = 0;
46909 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46910 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46911 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46912 ret_ref = (uintptr_t)ret_var.inner;
46913 if (ret_var.is_owned) {
46914         ret_ref |= 1;
46915 }
46916         return ret_ref;
46917 }
46918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46919         LDKDescription arg_conv;
46920         arg_conv.inner = (void*)(arg & (~1));
46921         arg_conv.is_owned = false;
46922         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46923         int64_t ret_conv = Description_clone_ptr(&arg_conv);
46924         return ret_conv;
46925 }
46926
46927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46928         LDKDescription orig_conv;
46929         orig_conv.inner = (void*)(orig & (~1));
46930         orig_conv.is_owned = false;
46931         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46932         LDKDescription ret_var = Description_clone(&orig_conv);
46933         int64_t ret_ref = 0;
46934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46937         ret_ref = (uintptr_t)ret_var.inner;
46938         if (ret_var.is_owned) {
46939                 ret_ref |= 1;
46940         }
46941         return ret_ref;
46942 }
46943
46944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
46945         LDKDescription o_conv;
46946         o_conv.inner = (void*)(o & (~1));
46947         o_conv.is_owned = false;
46948         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46949         int64_t ret_conv = Description_hash(&o_conv);
46950         return ret_conv;
46951 }
46952
46953 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46954         LDKDescription a_conv;
46955         a_conv.inner = (void*)(a & (~1));
46956         a_conv.is_owned = false;
46957         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46958         LDKDescription b_conv;
46959         b_conv.inner = (void*)(b & (~1));
46960         b_conv.is_owned = false;
46961         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46962         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
46963         return ret_conv;
46964 }
46965
46966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46967         LDKPayeePubKey this_obj_conv;
46968         this_obj_conv.inner = (void*)(this_obj & (~1));
46969         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46971         PayeePubKey_free(this_obj_conv);
46972 }
46973
46974 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
46975         LDKPayeePubKey this_ptr_conv;
46976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46977         this_ptr_conv.is_owned = false;
46978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46979         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46980         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
46981         return ret_arr;
46982 }
46983
46984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46985         LDKPayeePubKey this_ptr_conv;
46986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
46987         this_ptr_conv.is_owned = false;
46988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46989         LDKPublicKey val_ref;
46990         CHECK((*env)->GetArrayLength(env, val) == 33);
46991         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
46992         PayeePubKey_set_a(&this_ptr_conv, val_ref);
46993 }
46994
46995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
46996         LDKPublicKey a_arg_ref;
46997         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
46998         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
46999         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
47000         int64_t ret_ref = 0;
47001         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47002         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47004         ret_ref = (uintptr_t)ret_var.inner;
47005         if (ret_var.is_owned) {
47006                 ret_ref |= 1;
47007         }
47008         return ret_ref;
47009 }
47010
47011 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
47012         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
47013 int64_t ret_ref = 0;
47014 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47015 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47016 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47017 ret_ref = (uintptr_t)ret_var.inner;
47018 if (ret_var.is_owned) {
47019         ret_ref |= 1;
47020 }
47021         return ret_ref;
47022 }
47023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47024         LDKPayeePubKey arg_conv;
47025         arg_conv.inner = (void*)(arg & (~1));
47026         arg_conv.is_owned = false;
47027         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47028         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
47029         return ret_conv;
47030 }
47031
47032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47033         LDKPayeePubKey orig_conv;
47034         orig_conv.inner = (void*)(orig & (~1));
47035         orig_conv.is_owned = false;
47036         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47037         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
47038         int64_t ret_ref = 0;
47039         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47040         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47042         ret_ref = (uintptr_t)ret_var.inner;
47043         if (ret_var.is_owned) {
47044                 ret_ref |= 1;
47045         }
47046         return ret_ref;
47047 }
47048
47049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
47050         LDKPayeePubKey o_conv;
47051         o_conv.inner = (void*)(o & (~1));
47052         o_conv.is_owned = false;
47053         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47054         int64_t ret_conv = PayeePubKey_hash(&o_conv);
47055         return ret_conv;
47056 }
47057
47058 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47059         LDKPayeePubKey a_conv;
47060         a_conv.inner = (void*)(a & (~1));
47061         a_conv.is_owned = false;
47062         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47063         LDKPayeePubKey b_conv;
47064         b_conv.inner = (void*)(b & (~1));
47065         b_conv.is_owned = false;
47066         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47067         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
47068         return ret_conv;
47069 }
47070
47071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47072         LDKExpiryTime this_obj_conv;
47073         this_obj_conv.inner = (void*)(this_obj & (~1));
47074         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47076         ExpiryTime_free(this_obj_conv);
47077 }
47078
47079 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
47080         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
47081 int64_t ret_ref = 0;
47082 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47083 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47084 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47085 ret_ref = (uintptr_t)ret_var.inner;
47086 if (ret_var.is_owned) {
47087         ret_ref |= 1;
47088 }
47089         return ret_ref;
47090 }
47091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47092         LDKExpiryTime arg_conv;
47093         arg_conv.inner = (void*)(arg & (~1));
47094         arg_conv.is_owned = false;
47095         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47096         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
47097         return ret_conv;
47098 }
47099
47100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47101         LDKExpiryTime orig_conv;
47102         orig_conv.inner = (void*)(orig & (~1));
47103         orig_conv.is_owned = false;
47104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47105         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
47106         int64_t ret_ref = 0;
47107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47110         ret_ref = (uintptr_t)ret_var.inner;
47111         if (ret_var.is_owned) {
47112                 ret_ref |= 1;
47113         }
47114         return ret_ref;
47115 }
47116
47117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
47118         LDKExpiryTime o_conv;
47119         o_conv.inner = (void*)(o & (~1));
47120         o_conv.is_owned = false;
47121         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47122         int64_t ret_conv = ExpiryTime_hash(&o_conv);
47123         return ret_conv;
47124 }
47125
47126 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47127         LDKExpiryTime a_conv;
47128         a_conv.inner = (void*)(a & (~1));
47129         a_conv.is_owned = false;
47130         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47131         LDKExpiryTime b_conv;
47132         b_conv.inner = (void*)(b & (~1));
47133         b_conv.is_owned = false;
47134         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47135         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
47136         return ret_conv;
47137 }
47138
47139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47140         LDKMinFinalCltvExpiry this_obj_conv;
47141         this_obj_conv.inner = (void*)(this_obj & (~1));
47142         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47144         MinFinalCltvExpiry_free(this_obj_conv);
47145 }
47146
47147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
47148         LDKMinFinalCltvExpiry this_ptr_conv;
47149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47150         this_ptr_conv.is_owned = false;
47151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47152         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
47153         return ret_conv;
47154 }
47155
47156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47157         LDKMinFinalCltvExpiry this_ptr_conv;
47158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
47159         this_ptr_conv.is_owned = false;
47160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47161         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
47162 }
47163
47164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
47165         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
47166         int64_t ret_ref = 0;
47167         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47168         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47170         ret_ref = (uintptr_t)ret_var.inner;
47171         if (ret_var.is_owned) {
47172                 ret_ref |= 1;
47173         }
47174         return ret_ref;
47175 }
47176
47177 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
47178         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
47179 int64_t ret_ref = 0;
47180 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47181 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47182 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47183 ret_ref = (uintptr_t)ret_var.inner;
47184 if (ret_var.is_owned) {
47185         ret_ref |= 1;
47186 }
47187         return ret_ref;
47188 }
47189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47190         LDKMinFinalCltvExpiry arg_conv;
47191         arg_conv.inner = (void*)(arg & (~1));
47192         arg_conv.is_owned = false;
47193         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47194         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
47195         return ret_conv;
47196 }
47197
47198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47199         LDKMinFinalCltvExpiry orig_conv;
47200         orig_conv.inner = (void*)(orig & (~1));
47201         orig_conv.is_owned = false;
47202         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47203         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
47204         int64_t ret_ref = 0;
47205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47208         ret_ref = (uintptr_t)ret_var.inner;
47209         if (ret_var.is_owned) {
47210                 ret_ref |= 1;
47211         }
47212         return ret_ref;
47213 }
47214
47215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
47216         LDKMinFinalCltvExpiry o_conv;
47217         o_conv.inner = (void*)(o & (~1));
47218         o_conv.is_owned = false;
47219         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47220         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
47221         return ret_conv;
47222 }
47223
47224 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47225         LDKMinFinalCltvExpiry a_conv;
47226         a_conv.inner = (void*)(a & (~1));
47227         a_conv.is_owned = false;
47228         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47229         LDKMinFinalCltvExpiry b_conv;
47230         b_conv.inner = (void*)(b & (~1));
47231         b_conv.is_owned = false;
47232         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47233         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
47234         return ret_conv;
47235 }
47236
47237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47238         if ((this_ptr & 1) != 0) return;
47239         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
47240         CHECK_ACCESS(this_ptr_ptr);
47241         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
47242         FREE((void*)this_ptr);
47243         Fallback_free(this_ptr_conv);
47244 }
47245
47246 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
47247         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
47248         *ret_copy = Fallback_clone(arg);
47249 int64_t ret_ref = (uintptr_t)ret_copy;
47250         return ret_ref;
47251 }
47252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47253         LDKFallback* arg_conv = (LDKFallback*)arg;
47254         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
47255         return ret_conv;
47256 }
47257
47258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47259         LDKFallback* orig_conv = (LDKFallback*)orig;
47260         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
47261         *ret_copy = Fallback_clone(orig_conv);
47262         int64_t ret_ref = (uintptr_t)ret_copy;
47263         return ret_ref;
47264 }
47265
47266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
47267         
47268         LDKCVec_u8Z program_ref;
47269         program_ref.datalen = (*env)->GetArrayLength(env, program);
47270         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
47271         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
47272         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
47273         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
47274         int64_t ret_ref = (uintptr_t)ret_copy;
47275         return ret_ref;
47276 }
47277
47278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
47279         LDKTwentyBytes a_ref;
47280         CHECK((*env)->GetArrayLength(env, a) == 20);
47281         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
47282         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
47283         *ret_copy = Fallback_pub_key_hash(a_ref);
47284         int64_t ret_ref = (uintptr_t)ret_copy;
47285         return ret_ref;
47286 }
47287
47288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
47289         LDKTwentyBytes a_ref;
47290         CHECK((*env)->GetArrayLength(env, a) == 20);
47291         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
47292         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
47293         *ret_copy = Fallback_script_hash(a_ref);
47294         int64_t ret_ref = (uintptr_t)ret_copy;
47295         return ret_ref;
47296 }
47297
47298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
47299         LDKFallback* o_conv = (LDKFallback*)o;
47300         int64_t ret_conv = Fallback_hash(o_conv);
47301         return ret_conv;
47302 }
47303
47304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47305         LDKFallback* a_conv = (LDKFallback*)a;
47306         LDKFallback* b_conv = (LDKFallback*)b;
47307         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
47308         return ret_conv;
47309 }
47310
47311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47312         LDKInvoiceSignature this_obj_conv;
47313         this_obj_conv.inner = (void*)(this_obj & (~1));
47314         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47316         InvoiceSignature_free(this_obj_conv);
47317 }
47318
47319 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
47320         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
47321 int64_t ret_ref = 0;
47322 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47323 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47324 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47325 ret_ref = (uintptr_t)ret_var.inner;
47326 if (ret_var.is_owned) {
47327         ret_ref |= 1;
47328 }
47329         return ret_ref;
47330 }
47331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47332         LDKInvoiceSignature arg_conv;
47333         arg_conv.inner = (void*)(arg & (~1));
47334         arg_conv.is_owned = false;
47335         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47336         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
47337         return ret_conv;
47338 }
47339
47340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47341         LDKInvoiceSignature orig_conv;
47342         orig_conv.inner = (void*)(orig & (~1));
47343         orig_conv.is_owned = false;
47344         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47345         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
47346         int64_t ret_ref = 0;
47347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47350         ret_ref = (uintptr_t)ret_var.inner;
47351         if (ret_var.is_owned) {
47352                 ret_ref |= 1;
47353         }
47354         return ret_ref;
47355 }
47356
47357 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47358         LDKInvoiceSignature a_conv;
47359         a_conv.inner = (void*)(a & (~1));
47360         a_conv.is_owned = false;
47361         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47362         LDKInvoiceSignature b_conv;
47363         b_conv.inner = (void*)(b & (~1));
47364         b_conv.is_owned = false;
47365         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47366         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
47367         return ret_conv;
47368 }
47369
47370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47371         LDKPrivateRoute this_obj_conv;
47372         this_obj_conv.inner = (void*)(this_obj & (~1));
47373         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
47374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47375         PrivateRoute_free(this_obj_conv);
47376 }
47377
47378 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
47379         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
47380 int64_t ret_ref = 0;
47381 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47382 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47383 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47384 ret_ref = (uintptr_t)ret_var.inner;
47385 if (ret_var.is_owned) {
47386         ret_ref |= 1;
47387 }
47388         return ret_ref;
47389 }
47390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47391         LDKPrivateRoute arg_conv;
47392         arg_conv.inner = (void*)(arg & (~1));
47393         arg_conv.is_owned = false;
47394         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47395         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
47396         return ret_conv;
47397 }
47398
47399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47400         LDKPrivateRoute orig_conv;
47401         orig_conv.inner = (void*)(orig & (~1));
47402         orig_conv.is_owned = false;
47403         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47404         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
47405         int64_t ret_ref = 0;
47406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47409         ret_ref = (uintptr_t)ret_var.inner;
47410         if (ret_var.is_owned) {
47411                 ret_ref |= 1;
47412         }
47413         return ret_ref;
47414 }
47415
47416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
47417         LDKPrivateRoute o_conv;
47418         o_conv.inner = (void*)(o & (~1));
47419         o_conv.is_owned = false;
47420         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
47421         int64_t ret_conv = PrivateRoute_hash(&o_conv);
47422         return ret_conv;
47423 }
47424
47425 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47426         LDKPrivateRoute a_conv;
47427         a_conv.inner = (void*)(a & (~1));
47428         a_conv.is_owned = false;
47429         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47430         LDKPrivateRoute b_conv;
47431         b_conv.inner = (void*)(b & (~1));
47432         b_conv.is_owned = false;
47433         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47434         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
47435         return ret_conv;
47436 }
47437
47438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
47439         LDKSignedRawInvoice this_arg_conv;
47440         this_arg_conv.inner = (void*)(this_arg & (~1));
47441         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47443         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
47444         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
47445         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
47446         return ((int64_t)ret_conv);
47447 }
47448
47449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
47450         LDKSignedRawInvoice this_arg_conv;
47451         this_arg_conv.inner = (void*)(this_arg & (~1));
47452         this_arg_conv.is_owned = false;
47453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47454         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
47455         int64_t ret_ref = 0;
47456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47459         ret_ref = (uintptr_t)ret_var.inner;
47460         if (ret_var.is_owned) {
47461                 ret_ref |= 1;
47462         }
47463         return ret_ref;
47464 }
47465
47466 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47467         LDKSignedRawInvoice this_arg_conv;
47468         this_arg_conv.inner = (void*)(this_arg & (~1));
47469         this_arg_conv.is_owned = false;
47470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47471         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
47473         return ret_arr;
47474 }
47475
47476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
47477         LDKSignedRawInvoice this_arg_conv;
47478         this_arg_conv.inner = (void*)(this_arg & (~1));
47479         this_arg_conv.is_owned = false;
47480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47481         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
47482         int64_t ret_ref = 0;
47483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47486         ret_ref = (uintptr_t)ret_var.inner;
47487         if (ret_var.is_owned) {
47488                 ret_ref |= 1;
47489         }
47490         return ret_ref;
47491 }
47492
47493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
47494         LDKSignedRawInvoice this_arg_conv;
47495         this_arg_conv.inner = (void*)(this_arg & (~1));
47496         this_arg_conv.is_owned = false;
47497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47498         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
47499         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
47500         return (int64_t)ret_conv;
47501 }
47502
47503 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
47504         LDKSignedRawInvoice this_arg_conv;
47505         this_arg_conv.inner = (void*)(this_arg & (~1));
47506         this_arg_conv.is_owned = false;
47507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47508         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
47509         return ret_conv;
47510 }
47511
47512 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47513         LDKRawInvoice this_arg_conv;
47514         this_arg_conv.inner = (void*)(this_arg & (~1));
47515         this_arg_conv.is_owned = false;
47516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47517         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47518         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
47519         return ret_arr;
47520 }
47521
47522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47523         LDKRawInvoice this_arg_conv;
47524         this_arg_conv.inner = (void*)(this_arg & (~1));
47525         this_arg_conv.is_owned = false;
47526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47527         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
47528         int64_t ret_ref = 0;
47529         if ((uintptr_t)ret_var.inner > 4096) {
47530                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47531                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47533                 ret_ref = (uintptr_t)ret_var.inner;
47534                 if (ret_var.is_owned) {
47535                         ret_ref |= 1;
47536                 }
47537         }
47538         return ret_ref;
47539 }
47540
47541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
47542         LDKRawInvoice this_arg_conv;
47543         this_arg_conv.inner = (void*)(this_arg & (~1));
47544         this_arg_conv.is_owned = false;
47545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47546         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
47547         int64_t ret_ref = 0;
47548         if ((uintptr_t)ret_var.inner > 4096) {
47549                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47550                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47552                 ret_ref = (uintptr_t)ret_var.inner;
47553                 if (ret_var.is_owned) {
47554                         ret_ref |= 1;
47555                 }
47556         }
47557         return ret_ref;
47558 }
47559
47560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
47561         LDKRawInvoice this_arg_conv;
47562         this_arg_conv.inner = (void*)(this_arg & (~1));
47563         this_arg_conv.is_owned = false;
47564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47565         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
47566         int64_t ret_ref = 0;
47567         if ((uintptr_t)ret_var.inner > 4096) {
47568                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47569                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47571                 ret_ref = (uintptr_t)ret_var.inner;
47572                 if (ret_var.is_owned) {
47573                         ret_ref |= 1;
47574                 }
47575         }
47576         return ret_ref;
47577 }
47578
47579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47580         LDKRawInvoice this_arg_conv;
47581         this_arg_conv.inner = (void*)(this_arg & (~1));
47582         this_arg_conv.is_owned = false;
47583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47584         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
47585         int64_t ret_ref = 0;
47586         if ((uintptr_t)ret_var.inner > 4096) {
47587                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47588                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47590                 ret_ref = (uintptr_t)ret_var.inner;
47591                 if (ret_var.is_owned) {
47592                         ret_ref |= 1;
47593                 }
47594         }
47595         return ret_ref;
47596 }
47597
47598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
47599         LDKRawInvoice this_arg_conv;
47600         this_arg_conv.inner = (void*)(this_arg & (~1));
47601         this_arg_conv.is_owned = false;
47602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47603         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
47604         int64_t ret_ref = 0;
47605         if ((uintptr_t)ret_var.inner > 4096) {
47606                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47607                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47609                 ret_ref = (uintptr_t)ret_var.inner;
47610                 if (ret_var.is_owned) {
47611                         ret_ref |= 1;
47612                 }
47613         }
47614         return ret_ref;
47615 }
47616
47617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
47618         LDKRawInvoice this_arg_conv;
47619         this_arg_conv.inner = (void*)(this_arg & (~1));
47620         this_arg_conv.is_owned = false;
47621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47622         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
47623         int64_t ret_ref = 0;
47624         if ((uintptr_t)ret_var.inner > 4096) {
47625                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47626                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47628                 ret_ref = (uintptr_t)ret_var.inner;
47629                 if (ret_var.is_owned) {
47630                         ret_ref |= 1;
47631                 }
47632         }
47633         return ret_ref;
47634 }
47635
47636 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
47637         LDKRawInvoice this_arg_conv;
47638         this_arg_conv.inner = (void*)(this_arg & (~1));
47639         this_arg_conv.is_owned = false;
47640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47641         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47642         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
47643         return ret_arr;
47644 }
47645
47646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47647         LDKRawInvoice this_arg_conv;
47648         this_arg_conv.inner = (void*)(this_arg & (~1));
47649         this_arg_conv.is_owned = false;
47650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47651         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
47652         int64_t ret_ref = 0;
47653         if ((uintptr_t)ret_var.inner > 4096) {
47654                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47655                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47657                 ret_ref = (uintptr_t)ret_var.inner;
47658                 if (ret_var.is_owned) {
47659                         ret_ref |= 1;
47660                 }
47661         }
47662         return ret_ref;
47663 }
47664
47665 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
47666         LDKRawInvoice this_arg_conv;
47667         this_arg_conv.inner = (void*)(this_arg & (~1));
47668         this_arg_conv.is_owned = false;
47669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47670         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
47671         int64_tArray ret_arr = NULL;
47672         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47673         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47674         for (size_t o = 0; o < ret_var.datalen; o++) {
47675                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
47676                 int64_t ret_conv_14_ref = 0;
47677                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47678                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47679                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
47680                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
47681                 if (ret_conv_14_var.is_owned) {
47682                         ret_conv_14_ref |= 1;
47683                 }
47684                 ret_arr_ptr[o] = ret_conv_14_ref;
47685         }
47686         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47687         FREE(ret_var.data);
47688         return ret_arr;
47689 }
47690
47691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
47692         LDKRawInvoice this_arg_conv;
47693         this_arg_conv.inner = (void*)(this_arg & (~1));
47694         this_arg_conv.is_owned = false;
47695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47696         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47697         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
47698         int64_t ret_ref = (uintptr_t)ret_copy;
47699         return ret_ref;
47700 }
47701
47702 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
47703         LDKRawInvoice this_arg_conv;
47704         this_arg_conv.inner = (void*)(this_arg & (~1));
47705         this_arg_conv.is_owned = false;
47706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47707         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
47708         return ret_conv;
47709 }
47710
47711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
47712         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
47713         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
47714         return (int64_t)ret_conv;
47715 }
47716
47717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
47718         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
47719         *ret_conv = PositiveTimestamp_from_system_time(time);
47720         return (int64_t)ret_conv;
47721 }
47722
47723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
47724         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
47725         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
47726         return (int64_t)ret_conv;
47727 }
47728
47729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
47730         LDKPositiveTimestamp this_arg_conv;
47731         this_arg_conv.inner = (void*)(this_arg & (~1));
47732         this_arg_conv.is_owned = false;
47733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47734         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
47735         return ret_conv;
47736 }
47737
47738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
47739         LDKPositiveTimestamp this_arg_conv;
47740         this_arg_conv.inner = (void*)(this_arg & (~1));
47741         this_arg_conv.is_owned = false;
47742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47743         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
47744         return ret_conv;
47745 }
47746
47747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
47748         LDKPositiveTimestamp this_arg_conv;
47749         this_arg_conv.inner = (void*)(this_arg & (~1));
47750         this_arg_conv.is_owned = false;
47751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47752         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
47753         return ret_conv;
47754 }
47755
47756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
47757         LDKInvoice this_arg_conv;
47758         this_arg_conv.inner = (void*)(this_arg & (~1));
47759         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47761         this_arg_conv = Invoice_clone(&this_arg_conv);
47762         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
47763         int64_t ret_ref = 0;
47764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47767         ret_ref = (uintptr_t)ret_var.inner;
47768         if (ret_var.is_owned) {
47769                 ret_ref |= 1;
47770         }
47771         return ret_ref;
47772 }
47773
47774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
47775         LDKInvoice this_arg_conv;
47776         this_arg_conv.inner = (void*)(this_arg & (~1));
47777         this_arg_conv.is_owned = false;
47778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47779         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
47780         *ret_conv = Invoice_check_signature(&this_arg_conv);
47781         return (int64_t)ret_conv;
47782 }
47783
47784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
47785         LDKSignedRawInvoice signed_invoice_conv;
47786         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
47787         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
47788         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
47789         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
47790         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
47791         *ret_conv = Invoice_from_signed(signed_invoice_conv);
47792         return (int64_t)ret_conv;
47793 }
47794
47795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
47796         LDKInvoice this_arg_conv;
47797         this_arg_conv.inner = (void*)(this_arg & (~1));
47798         this_arg_conv.is_owned = false;
47799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47800         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
47801         return ret_conv;
47802 }
47803
47804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
47805         LDKInvoice this_arg_conv;
47806         this_arg_conv.inner = (void*)(this_arg & (~1));
47807         this_arg_conv.is_owned = false;
47808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47809         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
47810         return ret_conv;
47811 }
47812
47813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
47814         LDKInvoice this_arg_conv;
47815         this_arg_conv.inner = (void*)(this_arg & (~1));
47816         this_arg_conv.is_owned = false;
47817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47818         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47819         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
47820         return ret_arr;
47821 }
47822
47823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
47824         LDKInvoice this_arg_conv;
47825         this_arg_conv.inner = (void*)(this_arg & (~1));
47826         this_arg_conv.is_owned = false;
47827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47828         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47829         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
47830         return ret_arr;
47831 }
47832
47833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
47834         LDKInvoice this_arg_conv;
47835         this_arg_conv.inner = (void*)(this_arg & (~1));
47836         this_arg_conv.is_owned = false;
47837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47838         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47839         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
47840         return ret_arr;
47841 }
47842
47843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
47844         LDKInvoice this_arg_conv;
47845         this_arg_conv.inner = (void*)(this_arg & (~1));
47846         this_arg_conv.is_owned = false;
47847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47848         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
47849         int64_t ret_ref = 0;
47850         if ((uintptr_t)ret_var.inner > 4096) {
47851                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47852                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47854                 ret_ref = (uintptr_t)ret_var.inner;
47855                 if (ret_var.is_owned) {
47856                         ret_ref |= 1;
47857                 }
47858         }
47859         return ret_ref;
47860 }
47861
47862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
47863         LDKInvoice this_arg_conv;
47864         this_arg_conv.inner = (void*)(this_arg & (~1));
47865         this_arg_conv.is_owned = false;
47866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47867         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
47868         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
47869         return ret_arr;
47870 }
47871
47872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
47873         LDKInvoice this_arg_conv;
47874         this_arg_conv.inner = (void*)(this_arg & (~1));
47875         this_arg_conv.is_owned = false;
47876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47877         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
47878         return ret_conv;
47879 }
47880
47881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
47882         LDKInvoice this_arg_conv;
47883         this_arg_conv.inner = (void*)(this_arg & (~1));
47884         this_arg_conv.is_owned = false;
47885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47886         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
47887         return ret_conv;
47888 }
47889
47890 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
47891         LDKInvoice this_arg_conv;
47892         this_arg_conv.inner = (void*)(this_arg & (~1));
47893         this_arg_conv.is_owned = false;
47894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47895         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
47896         return ret_conv;
47897 }
47898
47899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
47900         LDKInvoice this_arg_conv;
47901         this_arg_conv.inner = (void*)(this_arg & (~1));
47902         this_arg_conv.is_owned = false;
47903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47904         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
47905         return ret_conv;
47906 }
47907
47908 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
47909         LDKInvoice this_arg_conv;
47910         this_arg_conv.inner = (void*)(this_arg & (~1));
47911         this_arg_conv.is_owned = false;
47912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47913         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
47914         int64_tArray ret_arr = NULL;
47915         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47916         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47917         for (size_t o = 0; o < ret_var.datalen; o++) {
47918                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
47919                 int64_t ret_conv_14_ref = 0;
47920                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47921                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47922                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
47923                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
47924                 if (ret_conv_14_var.is_owned) {
47925                         ret_conv_14_ref |= 1;
47926                 }
47927                 ret_arr_ptr[o] = ret_conv_14_ref;
47928         }
47929         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47930         FREE(ret_var.data);
47931         return ret_arr;
47932 }
47933
47934 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
47935         LDKInvoice this_arg_conv;
47936         this_arg_conv.inner = (void*)(this_arg & (~1));
47937         this_arg_conv.is_owned = false;
47938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47939         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
47940         int64_tArray ret_arr = NULL;
47941         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47942         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47943         for (size_t l = 0; l < ret_var.datalen; l++) {
47944                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
47945                 int64_t ret_conv_11_ref = 0;
47946                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
47947                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
47948                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
47949                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
47950                 if (ret_conv_11_var.is_owned) {
47951                         ret_conv_11_ref |= 1;
47952                 }
47953                 ret_arr_ptr[l] = ret_conv_11_ref;
47954         }
47955         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47956         FREE(ret_var.data);
47957         return ret_arr;
47958 }
47959
47960 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
47961         LDKInvoice this_arg_conv;
47962         this_arg_conv.inner = (void*)(this_arg & (~1));
47963         this_arg_conv.is_owned = false;
47964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47965         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
47966         return ret_conv;
47967 }
47968
47969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
47970         LDKInvoice this_arg_conv;
47971         this_arg_conv.inner = (void*)(this_arg & (~1));
47972         this_arg_conv.is_owned = false;
47973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47974         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
47975         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
47976         int64_t ret_ref = (uintptr_t)ret_copy;
47977         return ret_ref;
47978 }
47979
47980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
47981         LDKStr description_conv = java_to_owned_str(env, description);
47982         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
47983         *ret_conv = Description_new(description_conv);
47984         return (int64_t)ret_conv;
47985 }
47986
47987 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
47988         LDKDescription this_arg_conv;
47989         this_arg_conv.inner = (void*)(this_arg & (~1));
47990         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
47991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47992         this_arg_conv = Description_clone(&this_arg_conv);
47993         LDKStr ret_str = Description_into_inner(this_arg_conv);
47994         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47995         Str_free(ret_str);
47996         return ret_conv;
47997 }
47998
47999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
48000         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
48001         int64_t ret_ref = 0;
48002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48005         ret_ref = (uintptr_t)ret_var.inner;
48006         if (ret_var.is_owned) {
48007                 ret_ref |= 1;
48008         }
48009         return ret_ref;
48010 }
48011
48012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
48013         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
48014         int64_t ret_ref = 0;
48015         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48016         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48018         ret_ref = (uintptr_t)ret_var.inner;
48019         if (ret_var.is_owned) {
48020                 ret_ref |= 1;
48021         }
48022         return ret_ref;
48023 }
48024
48025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
48026         LDKExpiryTime this_arg_conv;
48027         this_arg_conv.inner = (void*)(this_arg & (~1));
48028         this_arg_conv.is_owned = false;
48029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48030         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
48031         return ret_conv;
48032 }
48033
48034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
48035         LDKExpiryTime this_arg_conv;
48036         this_arg_conv.inner = (void*)(this_arg & (~1));
48037         this_arg_conv.is_owned = false;
48038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48039         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
48040         return ret_conv;
48041 }
48042
48043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
48044         LDKRouteHint hops_conv;
48045         hops_conv.inner = (void*)(hops & (~1));
48046         hops_conv.is_owned = (hops & 1) || (hops == 0);
48047         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
48048         hops_conv = RouteHint_clone(&hops_conv);
48049         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
48050         *ret_conv = PrivateRoute_new(hops_conv);
48051         return (int64_t)ret_conv;
48052 }
48053
48054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
48055         LDKPrivateRoute this_arg_conv;
48056         this_arg_conv.inner = (void*)(this_arg & (~1));
48057         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
48058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48059         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
48060         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
48061         int64_t ret_ref = 0;
48062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48065         ret_ref = (uintptr_t)ret_var.inner;
48066         if (ret_var.is_owned) {
48067                 ret_ref |= 1;
48068         }
48069         return ret_ref;
48070 }
48071
48072 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48073         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
48074         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
48075         return ret_conv;
48076 }
48077
48078 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
48079         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
48080         return ret_conv;
48081 }
48082
48083 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
48084         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
48085         return ret_conv;
48086 }
48087
48088 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
48089         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
48090         return ret_conv;
48091 }
48092
48093 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
48094         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
48095         return ret_conv;
48096 }
48097
48098 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
48099         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
48100         return ret_conv;
48101 }
48102
48103 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48104         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
48105         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
48106         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
48107         return ret_conv;
48108 }
48109
48110 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48111         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
48112         LDKStr ret_str = CreationError_to_str(o_conv);
48113         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48114         Str_free(ret_str);
48115         return ret_conv;
48116 }
48117
48118 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48119         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
48120         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
48121         return ret_conv;
48122 }
48123
48124 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
48125         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
48126         return ret_conv;
48127 }
48128
48129 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
48130         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
48131         return ret_conv;
48132 }
48133
48134 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
48135         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
48136         return ret_conv;
48137 }
48138
48139 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
48140         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
48141         return ret_conv;
48142 }
48143
48144 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
48145         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
48146         return ret_conv;
48147 }
48148
48149 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
48150         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
48151         return ret_conv;
48152 }
48153
48154 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
48155         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
48156         return ret_conv;
48157 }
48158
48159 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
48160         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
48161         return ret_conv;
48162 }
48163
48164 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
48165         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
48166         return ret_conv;
48167 }
48168
48169 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
48170         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
48171         return ret_conv;
48172 }
48173
48174 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48175         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
48176         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
48177         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
48178         return ret_conv;
48179 }
48180
48181 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48182         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
48183         LDKStr ret_str = SemanticError_to_str(o_conv);
48184         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48185         Str_free(ret_str);
48186         return ret_conv;
48187 }
48188
48189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48190         if ((this_ptr & 1) != 0) return;
48191         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48192         CHECK_ACCESS(this_ptr_ptr);
48193         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
48194         FREE((void*)this_ptr);
48195         SignOrCreationError_free(this_ptr_conv);
48196 }
48197
48198 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
48199         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
48200         *ret_copy = SignOrCreationError_clone(arg);
48201 int64_t ret_ref = (uintptr_t)ret_copy;
48202         return ret_ref;
48203 }
48204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48205         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
48206         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
48207         return ret_conv;
48208 }
48209
48210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48211         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
48212         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
48213         *ret_copy = SignOrCreationError_clone(orig_conv);
48214         int64_t ret_ref = (uintptr_t)ret_copy;
48215         return ret_ref;
48216 }
48217
48218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
48219         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
48220         *ret_copy = SignOrCreationError_sign_error();
48221         int64_t ret_ref = (uintptr_t)ret_copy;
48222         return ret_ref;
48223 }
48224
48225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
48226         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
48227         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
48228         *ret_copy = SignOrCreationError_creation_error(a_conv);
48229         int64_t ret_ref = (uintptr_t)ret_copy;
48230         return ret_ref;
48231 }
48232
48233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48234         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
48235         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
48236         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
48237         return ret_conv;
48238 }
48239
48240 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48241         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
48242         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
48243         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48244         Str_free(ret_str);
48245         return ret_conv;
48246 }
48247
48248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48249         LDKInvoicePayer 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         InvoicePayer_free(this_obj_conv);
48254 }
48255
48256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48257         if ((this_ptr & 1) != 0) return;
48258         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48259         CHECK_ACCESS(this_ptr_ptr);
48260         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
48261         FREE((void*)this_ptr);
48262         Payer_free(this_ptr_conv);
48263 }
48264
48265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48266         if ((this_ptr & 1) != 0) return;
48267         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48268         CHECK_ACCESS(this_ptr_ptr);
48269         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
48270         FREE((void*)this_ptr);
48271         Router_free(this_ptr_conv);
48272 }
48273
48274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48275         if ((this_ptr & 1) != 0) return;
48276         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48277         CHECK_ACCESS(this_ptr_ptr);
48278         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
48279         FREE((void*)this_ptr);
48280         Retry_free(this_ptr_conv);
48281 }
48282
48283 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
48284         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
48285         *ret_copy = Retry_clone(arg);
48286 int64_t ret_ref = (uintptr_t)ret_copy;
48287         return ret_ref;
48288 }
48289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48290         LDKRetry* arg_conv = (LDKRetry*)arg;
48291         int64_t ret_conv = Retry_clone_ptr(arg_conv);
48292         return ret_conv;
48293 }
48294
48295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48296         LDKRetry* orig_conv = (LDKRetry*)orig;
48297         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
48298         *ret_copy = Retry_clone(orig_conv);
48299         int64_t ret_ref = (uintptr_t)ret_copy;
48300         return ret_ref;
48301 }
48302
48303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
48304         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
48305         *ret_copy = Retry_attempts(a);
48306         int64_t ret_ref = (uintptr_t)ret_copy;
48307         return ret_ref;
48308 }
48309
48310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
48311         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
48312         *ret_copy = Retry_timeout(a);
48313         int64_t ret_ref = (uintptr_t)ret_copy;
48314         return ret_ref;
48315 }
48316
48317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48318         LDKRetry* a_conv = (LDKRetry*)a;
48319         LDKRetry* b_conv = (LDKRetry*)b;
48320         jboolean ret_conv = Retry_eq(a_conv, b_conv);
48321         return ret_conv;
48322 }
48323
48324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
48325         LDKRetry* o_conv = (LDKRetry*)o;
48326         int64_t ret_conv = Retry_hash(o_conv);
48327         return ret_conv;
48328 }
48329
48330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48331         if ((this_ptr & 1) != 0) return;
48332         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48333         CHECK_ACCESS(this_ptr_ptr);
48334         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
48335         FREE((void*)this_ptr);
48336         PaymentError_free(this_ptr_conv);
48337 }
48338
48339 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
48340         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
48341         *ret_copy = PaymentError_clone(arg);
48342 int64_t ret_ref = (uintptr_t)ret_copy;
48343         return ret_ref;
48344 }
48345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48346         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
48347         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
48348         return ret_conv;
48349 }
48350
48351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48352         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
48353         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
48354         *ret_copy = PaymentError_clone(orig_conv);
48355         int64_t ret_ref = (uintptr_t)ret_copy;
48356         return ret_ref;
48357 }
48358
48359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
48360         LDKStr a_conv = java_to_owned_str(env, a);
48361         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
48362         *ret_copy = PaymentError_invoice(a_conv);
48363         int64_t ret_ref = (uintptr_t)ret_copy;
48364         return ret_ref;
48365 }
48366
48367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
48368         LDKLightningError a_conv;
48369         a_conv.inner = (void*)(a & (~1));
48370         a_conv.is_owned = (a & 1) || (a == 0);
48371         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48372         a_conv = LightningError_clone(&a_conv);
48373         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
48374         *ret_copy = PaymentError_routing(a_conv);
48375         int64_t ret_ref = (uintptr_t)ret_copy;
48376         return ret_ref;
48377 }
48378
48379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
48380         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
48381         CHECK_ACCESS(a_ptr);
48382         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
48383         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
48384         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
48385         *ret_copy = PaymentError_sending(a_conv);
48386         int64_t ret_ref = (uintptr_t)ret_copy;
48387         return ret_ref;
48388 }
48389
48390 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) {
48391         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
48392         CHECK_ACCESS(payer_ptr);
48393         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
48394         if (payer_conv.free == LDKPayer_JCalls_free) {
48395                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48396                 LDKPayer_JCalls_cloned(&payer_conv);
48397         }
48398         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
48399         CHECK_ACCESS(router_ptr);
48400         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
48401         if (router_conv.free == LDKRouter_JCalls_free) {
48402                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48403                 LDKRouter_JCalls_cloned(&router_conv);
48404         }
48405         LDKMultiThreadedLockableScore scorer_conv;
48406         scorer_conv.inner = (void*)(scorer & (~1));
48407         scorer_conv.is_owned = false;
48408         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
48409         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
48410         CHECK_ACCESS(logger_ptr);
48411         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48412         if (logger_conv.free == LDKLogger_JCalls_free) {
48413                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48414                 LDKLogger_JCalls_cloned(&logger_conv);
48415         }
48416         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
48417         CHECK_ACCESS(event_handler_ptr);
48418         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
48419         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
48420                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48421                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
48422         }
48423         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
48424         CHECK_ACCESS(retry_ptr);
48425         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
48426         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
48427         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
48428         int64_t ret_ref = 0;
48429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48432         ret_ref = (uintptr_t)ret_var.inner;
48433         if (ret_var.is_owned) {
48434                 ret_ref |= 1;
48435         }
48436         return ret_ref;
48437 }
48438
48439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
48440         LDKInvoicePayer this_arg_conv;
48441         this_arg_conv.inner = (void*)(this_arg & (~1));
48442         this_arg_conv.is_owned = false;
48443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48444         LDKInvoice invoice_conv;
48445         invoice_conv.inner = (void*)(invoice & (~1));
48446         invoice_conv.is_owned = false;
48447         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
48448         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
48449         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
48450         return (int64_t)ret_conv;
48451 }
48452
48453 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) {
48454         LDKInvoicePayer this_arg_conv;
48455         this_arg_conv.inner = (void*)(this_arg & (~1));
48456         this_arg_conv.is_owned = false;
48457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48458         LDKInvoice invoice_conv;
48459         invoice_conv.inner = (void*)(invoice & (~1));
48460         invoice_conv.is_owned = false;
48461         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
48462         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
48463         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
48464         return (int64_t)ret_conv;
48465 }
48466
48467 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) {
48468         LDKInvoicePayer this_arg_conv;
48469         this_arg_conv.inner = (void*)(this_arg & (~1));
48470         this_arg_conv.is_owned = false;
48471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48472         LDKPublicKey pubkey_ref;
48473         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
48474         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
48475         LDKThirtyTwoBytes payment_preimage_ref;
48476         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
48477         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
48478         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
48479         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
48480         return (int64_t)ret_conv;
48481 }
48482
48483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
48484         LDKInvoicePayer this_arg_conv;
48485         this_arg_conv.inner = (void*)(this_arg & (~1));
48486         this_arg_conv.is_owned = false;
48487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48488         unsigned char payment_hash_arr[32];
48489         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
48490         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
48491         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
48492         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
48493 }
48494
48495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
48496         LDKInvoicePayer 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         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
48501         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
48502         return (int64_t)ret_ret;
48503 }
48504
48505 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) {
48506         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48507         CHECK_ACCESS(amt_msat_ptr);
48508         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48509         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48510         LDKThirtyTwoBytes payment_hash_ref;
48511         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
48512         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
48513         LDKStr description_conv = java_to_owned_str(env, description);
48514         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
48515         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
48516         if (phantom_route_hints_constr.datalen > 0)
48517                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
48518         else
48519                 phantom_route_hints_constr.data = NULL;
48520         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
48521         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
48522                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
48523                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
48524                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
48525                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
48526                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
48527                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
48528                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
48529         }
48530         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
48531         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48532         CHECK_ACCESS(keys_manager_ptr);
48533         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48534         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48535                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48536                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48537         }
48538         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48539         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48540         *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);
48541         return (int64_t)ret_conv;
48542 }
48543
48544 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) {
48545         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48546         CHECK_ACCESS(amt_msat_ptr);
48547         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48548         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48549         LDKThirtyTwoBytes payment_hash_ref;
48550         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
48551         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
48552         LDKSha256 description_hash_conv;
48553         description_hash_conv.inner = (void*)(description_hash & (~1));
48554         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
48555         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
48556         description_hash_conv = Sha256_clone(&description_hash_conv);
48557         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
48558         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
48559         if (phantom_route_hints_constr.datalen > 0)
48560                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
48561         else
48562                 phantom_route_hints_constr.data = NULL;
48563         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
48564         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
48565                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
48566                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
48567                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
48568                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
48569                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
48570                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
48571                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
48572         }
48573         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
48574         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48575         CHECK_ACCESS(keys_manager_ptr);
48576         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48577         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48578                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48579                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48580         }
48581         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48582         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48583         *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);
48584         return (int64_t)ret_conv;
48585 }
48586
48587 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) {
48588         LDKChannelManager channelmanager_conv;
48589         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48590         channelmanager_conv.is_owned = false;
48591         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48592         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48593         CHECK_ACCESS(keys_manager_ptr);
48594         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48595         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48596                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48597                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48598         }
48599         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48600         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48601         CHECK_ACCESS(amt_msat_ptr);
48602         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48603         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48604         LDKStr description_conv = java_to_owned_str(env, description);
48605         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48606         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
48607         return (int64_t)ret_conv;
48608 }
48609
48610 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) {
48611         LDKChannelManager channelmanager_conv;
48612         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48613         channelmanager_conv.is_owned = false;
48614         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48615         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48616         CHECK_ACCESS(keys_manager_ptr);
48617         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48618         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48619                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48620                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48621         }
48622         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48623         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48624         CHECK_ACCESS(amt_msat_ptr);
48625         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48626         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48627         LDKSha256 description_hash_conv;
48628         description_hash_conv.inner = (void*)(description_hash & (~1));
48629         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
48630         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
48631         description_hash_conv = Sha256_clone(&description_hash_conv);
48632         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48633         *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);
48634         return (int64_t)ret_conv;
48635 }
48636
48637 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) {
48638         LDKChannelManager channelmanager_conv;
48639         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48640         channelmanager_conv.is_owned = false;
48641         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48642         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48643         CHECK_ACCESS(keys_manager_ptr);
48644         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48645         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48646                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48647                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48648         }
48649         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48650         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48651         CHECK_ACCESS(amt_msat_ptr);
48652         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48653         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48654         LDKSha256 description_hash_conv;
48655         description_hash_conv.inner = (void*)(description_hash & (~1));
48656         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
48657         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
48658         description_hash_conv = Sha256_clone(&description_hash_conv);
48659         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48660         *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);
48661         return (int64_t)ret_conv;
48662 }
48663
48664 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) {
48665         LDKChannelManager channelmanager_conv;
48666         channelmanager_conv.inner = (void*)(channelmanager & (~1));
48667         channelmanager_conv.is_owned = false;
48668         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
48669         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
48670         CHECK_ACCESS(keys_manager_ptr);
48671         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
48672         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
48673                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48674                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
48675         }
48676         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
48677         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
48678         CHECK_ACCESS(amt_msat_ptr);
48679         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
48680         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
48681         LDKStr description_conv = java_to_owned_str(env, description);
48682         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
48683         *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);
48684         return (int64_t)ret_conv;
48685 }
48686
48687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48688         LDKDefaultRouter this_obj_conv;
48689         this_obj_conv.inner = (void*)(this_obj & (~1));
48690         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48692         DefaultRouter_free(this_obj_conv);
48693 }
48694
48695 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) {
48696         LDKNetworkGraph network_graph_conv;
48697         network_graph_conv.inner = (void*)(network_graph & (~1));
48698         network_graph_conv.is_owned = false;
48699         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48700         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
48701         CHECK_ACCESS(logger_ptr);
48702         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
48703         if (logger_conv.free == LDKLogger_JCalls_free) {
48704                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
48705                 LDKLogger_JCalls_cloned(&logger_conv);
48706         }
48707         LDKThirtyTwoBytes random_seed_bytes_ref;
48708         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
48709         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
48710         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
48711         int64_t ret_ref = 0;
48712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48715         ret_ref = (uintptr_t)ret_var.inner;
48716         if (ret_var.is_owned) {
48717                 ret_ref |= 1;
48718         }
48719         return ret_ref;
48720 }
48721
48722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
48723         LDKDefaultRouter this_arg_conv;
48724         this_arg_conv.inner = (void*)(this_arg & (~1));
48725         this_arg_conv.is_owned = false;
48726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48727         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
48728         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
48729         return (int64_t)ret_ret;
48730 }
48731
48732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
48733         LDKChannelManager this_arg_conv;
48734         this_arg_conv.inner = (void*)(this_arg & (~1));
48735         this_arg_conv.is_owned = false;
48736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48737         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
48738         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
48739         return (int64_t)ret_ret;
48740 }
48741
48742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
48743         LDKStr s_conv = java_to_owned_str(env, s);
48744         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
48745         *ret_conv = SiPrefix_from_str(s_conv);
48746         return (int64_t)ret_conv;
48747 }
48748
48749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
48750         LDKStr s_conv = java_to_owned_str(env, s);
48751         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
48752         *ret_conv = Invoice_from_str(s_conv);
48753         return (int64_t)ret_conv;
48754 }
48755
48756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
48757         LDKStr s_conv = java_to_owned_str(env, s);
48758         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
48759         *ret_conv = SignedRawInvoice_from_str(s_conv);
48760         return (int64_t)ret_conv;
48761 }
48762
48763 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48764         LDKParseError* o_conv = (LDKParseError*)o;
48765         LDKStr ret_str = ParseError_to_str(o_conv);
48766         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48767         Str_free(ret_str);
48768         return ret_conv;
48769 }
48770
48771 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48772         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
48773         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
48774         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48775         Str_free(ret_str);
48776         return ret_conv;
48777 }
48778
48779 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48780         LDKInvoice o_conv;
48781         o_conv.inner = (void*)(o & (~1));
48782         o_conv.is_owned = false;
48783         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48784         LDKStr ret_str = Invoice_to_str(&o_conv);
48785         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48786         Str_free(ret_str);
48787         return ret_conv;
48788 }
48789
48790 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48791         LDKSignedRawInvoice o_conv;
48792         o_conv.inner = (void*)(o & (~1));
48793         o_conv.is_owned = false;
48794         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48795         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
48796         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48797         Str_free(ret_str);
48798         return ret_conv;
48799 }
48800
48801 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48802         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
48803         LDKStr ret_str = Currency_to_str(o_conv);
48804         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48805         Str_free(ret_str);
48806         return ret_conv;
48807 }
48808
48809 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
48810         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
48811         LDKStr ret_str = SiPrefix_to_str(o_conv);
48812         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
48813         Str_free(ret_str);
48814         return ret_conv;
48815 }
48816
48817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48818         LDKRapidGossipSync this_obj_conv;
48819         this_obj_conv.inner = (void*)(this_obj & (~1));
48820         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
48821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48822         RapidGossipSync_free(this_obj_conv);
48823 }
48824
48825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
48826         LDKNetworkGraph network_graph_conv;
48827         network_graph_conv.inner = (void*)(network_graph & (~1));
48828         network_graph_conv.is_owned = false;
48829         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
48830         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
48831         int64_t ret_ref = 0;
48832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
48833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
48834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48835         ret_ref = (uintptr_t)ret_var.inner;
48836         if (ret_var.is_owned) {
48837                 ret_ref |= 1;
48838         }
48839         return ret_ref;
48840 }
48841
48842 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) {
48843         LDKRapidGossipSync this_arg_conv;
48844         this_arg_conv.inner = (void*)(this_arg & (~1));
48845         this_arg_conv.is_owned = false;
48846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48847         LDKStr sync_path_conv = java_to_owned_str(env, sync_path);
48848         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
48849         *ret_conv = RapidGossipSync_sync_network_graph_with_file_path(&this_arg_conv, sync_path_conv);
48850         return (int64_t)ret_conv;
48851 }
48852
48853 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
48854         LDKRapidGossipSync this_arg_conv;
48855         this_arg_conv.inner = (void*)(this_arg & (~1));
48856         this_arg_conv.is_owned = false;
48857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48858         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
48859         return ret_conv;
48860 }
48861
48862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48863         if ((this_ptr & 1) != 0) return;
48864         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
48865         CHECK_ACCESS(this_ptr_ptr);
48866         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
48867         FREE((void*)this_ptr);
48868         GraphSyncError_free(this_ptr_conv);
48869 }
48870
48871 static inline uintptr_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
48872         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48873         *ret_copy = GraphSyncError_clone(arg);
48874 int64_t ret_ref = (uintptr_t)ret_copy;
48875         return ret_ref;
48876 }
48877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48878         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)arg;
48879         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
48880         return ret_conv;
48881 }
48882
48883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48884         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)orig;
48885         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48886         *ret_copy = GraphSyncError_clone(orig_conv);
48887         int64_t ret_ref = (uintptr_t)ret_copy;
48888         return ret_ref;
48889 }
48890
48891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
48892         LDKDecodeError a_conv;
48893         a_conv.inner = (void*)(a & (~1));
48894         a_conv.is_owned = (a & 1) || (a == 0);
48895         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48896         a_conv = DecodeError_clone(&a_conv);
48897         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48898         *ret_copy = GraphSyncError_decode_error(a_conv);
48899         int64_t ret_ref = (uintptr_t)ret_copy;
48900         return ret_ref;
48901 }
48902
48903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
48904         LDKLightningError a_conv;
48905         a_conv.inner = (void*)(a & (~1));
48906         a_conv.is_owned = (a & 1) || (a == 0);
48907         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48908         a_conv = LightningError_clone(&a_conv);
48909         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
48910         *ret_copy = GraphSyncError_lightning_error(a_conv);
48911         int64_t ret_ref = (uintptr_t)ret_copy;
48912         return ret_ref;
48913 }
48914
48915 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) {
48916         LDKRapidGossipSync this_arg_conv;
48917         this_arg_conv.inner = (void*)(this_arg & (~1));
48918         this_arg_conv.is_owned = false;
48919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48920         LDKu8slice update_data_ref;
48921         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
48922         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
48923         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
48924         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
48925         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
48926         return (int64_t)ret_conv;
48927 }
48928