Merge pull request #95 from TheBlueMatt/main
[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_InvalidRecoveryId;
683                 case 6: return LDKSecp256k1Error_InvalidTweak;
684                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
685                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
686         }
687         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
688         abort(); // Unreachable, but will let the compiler know we don't return here
689 }
690 static jclass Secp256k1Error_class = NULL;
691 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
692 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
693 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
694 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
695 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
696 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
697 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
698 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
699 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
700 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
701         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
702         CHECK(Secp256k1Error_class != NULL);
703         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
704         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
705         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
706         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
707         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
708         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
709         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
710         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
711         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
712         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
713         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
714         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
715         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
716         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
717         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
718         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
719         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
720         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
721 }
722 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
723         switch (val) {
724                 case LDKSecp256k1Error_IncorrectSignature:
725                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
726                 case LDKSecp256k1Error_InvalidMessage:
727                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
728                 case LDKSecp256k1Error_InvalidPublicKey:
729                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
730                 case LDKSecp256k1Error_InvalidSignature:
731                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
732                 case LDKSecp256k1Error_InvalidSecretKey:
733                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
734                 case LDKSecp256k1Error_InvalidRecoveryId:
735                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
736                 case LDKSecp256k1Error_InvalidTweak:
737                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
738                 case LDKSecp256k1Error_TweakCheckFailed:
739                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
740                 case LDKSecp256k1Error_NotEnoughMemory:
741                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
742                 default: abort();
743         }
744 }
745
746 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
747         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
748         if (UNLIKELY((*env)->ExceptionCheck(env))) {
749                 (*env)->ExceptionDescribe(env);
750                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
751         }
752         switch (ord) {
753                 case 0: return LDKSemanticError_NoPaymentHash;
754                 case 1: return LDKSemanticError_MultiplePaymentHashes;
755                 case 2: return LDKSemanticError_NoDescription;
756                 case 3: return LDKSemanticError_MultipleDescriptions;
757                 case 4: return LDKSemanticError_NoPaymentSecret;
758                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
759                 case 6: return LDKSemanticError_InvalidFeatures;
760                 case 7: return LDKSemanticError_InvalidRecoveryId;
761                 case 8: return LDKSemanticError_InvalidSignature;
762                 case 9: return LDKSemanticError_ImpreciseAmount;
763         }
764         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
765         abort(); // Unreachable, but will let the compiler know we don't return here
766 }
767 static jclass SemanticError_class = NULL;
768 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
769 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
770 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
771 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
772 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
773 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
774 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
775 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
776 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
777 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
778 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
779         SemanticError_class = (*env)->NewGlobalRef(env, clz);
780         CHECK(SemanticError_class != NULL);
781         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
782         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
783         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
784         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
785         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
786         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
787         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
788         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
789         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
790         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
791         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
792         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
793         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
794         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
795         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
796         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
797         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
798         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
799         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
800         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
801 }
802 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
803         switch (val) {
804                 case LDKSemanticError_NoPaymentHash:
805                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
806                 case LDKSemanticError_MultiplePaymentHashes:
807                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
808                 case LDKSemanticError_NoDescription:
809                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
810                 case LDKSemanticError_MultipleDescriptions:
811                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
812                 case LDKSemanticError_NoPaymentSecret:
813                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
814                 case LDKSemanticError_MultiplePaymentSecrets:
815                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
816                 case LDKSemanticError_InvalidFeatures:
817                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
818                 case LDKSemanticError_InvalidRecoveryId:
819                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
820                 case LDKSemanticError_InvalidSignature:
821                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
822                 case LDKSemanticError_ImpreciseAmount:
823                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
824                 default: abort();
825         }
826 }
827
828 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
829         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
830         if (UNLIKELY((*env)->ExceptionCheck(env))) {
831                 (*env)->ExceptionDescribe(env);
832                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
833         }
834         switch (ord) {
835                 case 0: return LDKSiPrefix_Milli;
836                 case 1: return LDKSiPrefix_Micro;
837                 case 2: return LDKSiPrefix_Nano;
838                 case 3: return LDKSiPrefix_Pico;
839         }
840         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
841         abort(); // Unreachable, but will let the compiler know we don't return here
842 }
843 static jclass SiPrefix_class = NULL;
844 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
845 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
846 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
847 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
848 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
849         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
850         CHECK(SiPrefix_class != NULL);
851         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
852         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
853         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
854         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
855         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
856         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
857         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
858         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
859 }
860 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
861         switch (val) {
862                 case LDKSiPrefix_Milli:
863                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
864                 case LDKSiPrefix_Micro:
865                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
866                 case LDKSiPrefix_Nano:
867                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
868                 case LDKSiPrefix_Pico:
869                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
870                 default: abort();
871         }
872 }
873
874 static jclass LDKBech32Error_MissingSeparator_class = NULL;
875 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
876 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
877 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
878 static jclass LDKBech32Error_InvalidLength_class = NULL;
879 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
880 static jclass LDKBech32Error_InvalidChar_class = NULL;
881 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
882 static jclass LDKBech32Error_InvalidData_class = NULL;
883 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
884 static jclass LDKBech32Error_InvalidPadding_class = NULL;
885 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
886 static jclass LDKBech32Error_MixedCase_class = NULL;
887 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
889         LDKBech32Error_MissingSeparator_class =
890                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
891         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
892         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
893         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
894         LDKBech32Error_InvalidChecksum_class =
895                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
896         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
897         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
898         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
899         LDKBech32Error_InvalidLength_class =
900                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
901         CHECK(LDKBech32Error_InvalidLength_class != NULL);
902         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
903         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
904         LDKBech32Error_InvalidChar_class =
905                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
906         CHECK(LDKBech32Error_InvalidChar_class != NULL);
907         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
908         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
909         LDKBech32Error_InvalidData_class =
910                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
911         CHECK(LDKBech32Error_InvalidData_class != NULL);
912         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
913         CHECK(LDKBech32Error_InvalidData_meth != NULL);
914         LDKBech32Error_InvalidPadding_class =
915                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
916         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
917         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
918         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
919         LDKBech32Error_MixedCase_class =
920                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
921         CHECK(LDKBech32Error_MixedCase_class != NULL);
922         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
923         CHECK(LDKBech32Error_MixedCase_meth != NULL);
924 }
925 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
926         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
927         switch(obj->tag) {
928                 case LDKBech32Error_MissingSeparator: {
929                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
930                 }
931                 case LDKBech32Error_InvalidChecksum: {
932                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
933                 }
934                 case LDKBech32Error_InvalidLength: {
935                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
936                 }
937                 case LDKBech32Error_InvalidChar: {
938                         int32_t invalid_char_conv = obj->invalid_char;
939                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
940                 }
941                 case LDKBech32Error_InvalidData: {
942                         int8_t invalid_data_conv = obj->invalid_data;
943                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
944                 }
945                 case LDKBech32Error_InvalidPadding: {
946                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
947                 }
948                 case LDKBech32Error_MixedCase: {
949                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
950                 }
951                 default: abort();
952         }
953 }
954 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
955         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
956         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
957         return ret;
958 }
959 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) {
960         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
961         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
962         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
963         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
964         CVec_u8Z_free(ret_var);
965         return ret_arr;
966 }
967
968 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) {
969         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
970         int64_t ret_conv = TxOut_get_value(thing_conv);
971         return ret_conv;
972 }
973
974 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
975 CHECK(owner->result_ok);
976         return *owner->contents.result;
977 }
978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
979         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
980         CResult_NoneNoneZ_get_ok(owner_conv);
981 }
982
983 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
984 CHECK(!owner->result_ok);
985         return *owner->contents.err;
986 }
987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
988         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
989         CResult_NoneNoneZ_get_err(owner_conv);
990 }
991
992 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
993 CHECK(owner->result_ok);
994         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
995 }
996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
997         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
998         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
999         int64_t ret_ref = 0;
1000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1003         ret_ref = (uintptr_t)ret_var.inner;
1004         if (ret_var.is_owned) {
1005                 ret_ref |= 1;
1006         }
1007         return ret_ref;
1008 }
1009
1010 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1011 CHECK(!owner->result_ok);
1012         return DecodeError_clone(&*owner->contents.err);
1013 }
1014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1015         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
1016         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1017         int64_t ret_ref = 0;
1018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1021         ret_ref = (uintptr_t)ret_var.inner;
1022         if (ret_var.is_owned) {
1023                 ret_ref |= 1;
1024         }
1025         return ret_ref;
1026 }
1027
1028 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1029 CHECK(owner->result_ok);
1030         return *owner->contents.result;
1031 }
1032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1033         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1034         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1035         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1036         return ret_arr;
1037 }
1038
1039 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1040 CHECK(!owner->result_ok);
1041         return *owner->contents.err;
1042 }
1043 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1044         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
1045         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1046         return ret_conv;
1047 }
1048
1049 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1050 CHECK(owner->result_ok);
1051         return *owner->contents.result;
1052 }
1053 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1054         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1055         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1056         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1057         return ret_arr;
1058 }
1059
1060 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1061 CHECK(!owner->result_ok);
1062         return *owner->contents.err;
1063 }
1064 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1065         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
1066         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1067         return ret_conv;
1068 }
1069
1070 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1071 CHECK(owner->result_ok);
1072         return TxCreationKeys_clone(&*owner->contents.result);
1073 }
1074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1075         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1076         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1077         int64_t ret_ref = 0;
1078         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1079         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1081         ret_ref = (uintptr_t)ret_var.inner;
1082         if (ret_var.is_owned) {
1083                 ret_ref |= 1;
1084         }
1085         return ret_ref;
1086 }
1087
1088 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1089 CHECK(!owner->result_ok);
1090         return DecodeError_clone(&*owner->contents.err);
1091 }
1092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1093         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
1094         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1095         int64_t ret_ref = 0;
1096         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1097         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1099         ret_ref = (uintptr_t)ret_var.inner;
1100         if (ret_var.is_owned) {
1101                 ret_ref |= 1;
1102         }
1103         return ret_ref;
1104 }
1105
1106 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1107 CHECK(owner->result_ok);
1108         return ChannelPublicKeys_clone(&*owner->contents.result);
1109 }
1110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1111         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1112         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1113         int64_t ret_ref = 0;
1114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1117         ret_ref = (uintptr_t)ret_var.inner;
1118         if (ret_var.is_owned) {
1119                 ret_ref |= 1;
1120         }
1121         return ret_ref;
1122 }
1123
1124 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1125 CHECK(!owner->result_ok);
1126         return DecodeError_clone(&*owner->contents.err);
1127 }
1128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1129         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
1130         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1131         int64_t ret_ref = 0;
1132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1135         ret_ref = (uintptr_t)ret_var.inner;
1136         if (ret_var.is_owned) {
1137                 ret_ref |= 1;
1138         }
1139         return ret_ref;
1140 }
1141
1142 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1143 CHECK(owner->result_ok);
1144         return TxCreationKeys_clone(&*owner->contents.result);
1145 }
1146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1147         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1148         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1149         int64_t ret_ref = 0;
1150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1153         ret_ref = (uintptr_t)ret_var.inner;
1154         if (ret_var.is_owned) {
1155                 ret_ref |= 1;
1156         }
1157         return ret_ref;
1158 }
1159
1160 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1161 CHECK(!owner->result_ok);
1162         return *owner->contents.err;
1163 }
1164 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1165         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
1166         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1167         return ret_conv;
1168 }
1169
1170 static jclass LDKCOption_u32Z_Some_class = NULL;
1171 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1172 static jclass LDKCOption_u32Z_None_class = NULL;
1173 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1175         LDKCOption_u32Z_Some_class =
1176                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1177         CHECK(LDKCOption_u32Z_Some_class != NULL);
1178         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1179         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1180         LDKCOption_u32Z_None_class =
1181                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1182         CHECK(LDKCOption_u32Z_None_class != NULL);
1183         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1184         CHECK(LDKCOption_u32Z_None_meth != NULL);
1185 }
1186 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1187         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
1188         switch(obj->tag) {
1189                 case LDKCOption_u32Z_Some: {
1190                         int32_t some_conv = obj->some;
1191                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1192                 }
1193                 case LDKCOption_u32Z_None: {
1194                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1195                 }
1196                 default: abort();
1197         }
1198 }
1199 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1200 CHECK(owner->result_ok);
1201         return HTLCOutputInCommitment_clone(&*owner->contents.result);
1202 }
1203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1204         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1205         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1206         int64_t ret_ref = 0;
1207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1210         ret_ref = (uintptr_t)ret_var.inner;
1211         if (ret_var.is_owned) {
1212                 ret_ref |= 1;
1213         }
1214         return ret_ref;
1215 }
1216
1217 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1218 CHECK(!owner->result_ok);
1219         return DecodeError_clone(&*owner->contents.err);
1220 }
1221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1222         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
1223         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1224         int64_t ret_ref = 0;
1225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1228         ret_ref = (uintptr_t)ret_var.inner;
1229         if (ret_var.is_owned) {
1230                 ret_ref |= 1;
1231         }
1232         return ret_ref;
1233 }
1234
1235 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1236 CHECK(owner->result_ok);
1237         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
1238 }
1239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1240         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1241         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1242         int64_t ret_ref = 0;
1243         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1244         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1246         ret_ref = (uintptr_t)ret_var.inner;
1247         if (ret_var.is_owned) {
1248                 ret_ref |= 1;
1249         }
1250         return ret_ref;
1251 }
1252
1253 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1254 CHECK(!owner->result_ok);
1255         return DecodeError_clone(&*owner->contents.err);
1256 }
1257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1258         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1259         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1260         int64_t ret_ref = 0;
1261         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1262         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1264         ret_ref = (uintptr_t)ret_var.inner;
1265         if (ret_var.is_owned) {
1266                 ret_ref |= 1;
1267         }
1268         return ret_ref;
1269 }
1270
1271 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1272 CHECK(owner->result_ok);
1273         return ChannelTransactionParameters_clone(&*owner->contents.result);
1274 }
1275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1276         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1277         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1278         int64_t ret_ref = 0;
1279         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1280         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1282         ret_ref = (uintptr_t)ret_var.inner;
1283         if (ret_var.is_owned) {
1284                 ret_ref |= 1;
1285         }
1286         return ret_ref;
1287 }
1288
1289 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1290 CHECK(!owner->result_ok);
1291         return DecodeError_clone(&*owner->contents.err);
1292 }
1293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1294         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
1295         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1296         int64_t ret_ref = 0;
1297         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1298         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1300         ret_ref = (uintptr_t)ret_var.inner;
1301         if (ret_var.is_owned) {
1302                 ret_ref |= 1;
1303         }
1304         return ret_ref;
1305 }
1306
1307 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1308 CHECK(owner->result_ok);
1309         return HolderCommitmentTransaction_clone(&*owner->contents.result);
1310 }
1311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1312         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1313         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1314         int64_t ret_ref = 0;
1315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1318         ret_ref = (uintptr_t)ret_var.inner;
1319         if (ret_var.is_owned) {
1320                 ret_ref |= 1;
1321         }
1322         return ret_ref;
1323 }
1324
1325 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1326 CHECK(!owner->result_ok);
1327         return DecodeError_clone(&*owner->contents.err);
1328 }
1329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1330         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1331         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1332         int64_t ret_ref = 0;
1333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1336         ret_ref = (uintptr_t)ret_var.inner;
1337         if (ret_var.is_owned) {
1338                 ret_ref |= 1;
1339         }
1340         return ret_ref;
1341 }
1342
1343 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1344 CHECK(owner->result_ok);
1345         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
1346 }
1347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1348         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1349         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1350         int64_t ret_ref = 0;
1351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1354         ret_ref = (uintptr_t)ret_var.inner;
1355         if (ret_var.is_owned) {
1356                 ret_ref |= 1;
1357         }
1358         return ret_ref;
1359 }
1360
1361 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1362 CHECK(!owner->result_ok);
1363         return DecodeError_clone(&*owner->contents.err);
1364 }
1365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1366         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
1367         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1368         int64_t ret_ref = 0;
1369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1372         ret_ref = (uintptr_t)ret_var.inner;
1373         if (ret_var.is_owned) {
1374                 ret_ref |= 1;
1375         }
1376         return ret_ref;
1377 }
1378
1379 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1380 CHECK(owner->result_ok);
1381         return &*owner->contents.result;
1382 }
1383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1384         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1385         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1386         int64_t ret_ref = 0;
1387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1390         ret_ref = (uintptr_t)ret_var.inner & ~1;
1391         return ret_ref;
1392 }
1393
1394 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1395 CHECK(!owner->result_ok);
1396         return *owner->contents.err;
1397 }
1398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1399         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
1400         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1401 }
1402
1403 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1404 CHECK(owner->result_ok);
1405         return CommitmentTransaction_clone(&*owner->contents.result);
1406 }
1407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1408         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1409         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1410         int64_t ret_ref = 0;
1411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1414         ret_ref = (uintptr_t)ret_var.inner;
1415         if (ret_var.is_owned) {
1416                 ret_ref |= 1;
1417         }
1418         return ret_ref;
1419 }
1420
1421 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1422 CHECK(!owner->result_ok);
1423         return DecodeError_clone(&*owner->contents.err);
1424 }
1425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1426         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
1427         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1428         int64_t ret_ref = 0;
1429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1432         ret_ref = (uintptr_t)ret_var.inner;
1433         if (ret_var.is_owned) {
1434                 ret_ref |= 1;
1435         }
1436         return ret_ref;
1437 }
1438
1439 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1440 CHECK(owner->result_ok);
1441         return &*owner->contents.result;
1442 }
1443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1444         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1445         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1446         int64_t ret_ref = 0;
1447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1450         ret_ref = (uintptr_t)ret_var.inner & ~1;
1451         return ret_ref;
1452 }
1453
1454 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1455 CHECK(!owner->result_ok);
1456         return *owner->contents.err;
1457 }
1458 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1459         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
1460         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1461 }
1462
1463 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1464 CHECK(owner->result_ok);
1465         return *owner->contents.result;
1466 }
1467 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1468         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1469         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1470         jobjectArray ret_arr = NULL;
1471         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1472         ;
1473         for (size_t i = 0; i < ret_var.datalen; i++) {
1474                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1475                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1476                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1477         }
1478         
1479         return ret_arr;
1480 }
1481
1482 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1483 CHECK(!owner->result_ok);
1484         return *owner->contents.err;
1485 }
1486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1487         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
1488         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1489 }
1490
1491 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1492 CHECK(owner->result_ok);
1493         return ShutdownScript_clone(&*owner->contents.result);
1494 }
1495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1496         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1497         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1498         int64_t ret_ref = 0;
1499         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1500         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1502         ret_ref = (uintptr_t)ret_var.inner;
1503         if (ret_var.is_owned) {
1504                 ret_ref |= 1;
1505         }
1506         return ret_ref;
1507 }
1508
1509 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1510 CHECK(!owner->result_ok);
1511         return DecodeError_clone(&*owner->contents.err);
1512 }
1513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1514         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
1515         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1516         int64_t ret_ref = 0;
1517         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1518         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1520         ret_ref = (uintptr_t)ret_var.inner;
1521         if (ret_var.is_owned) {
1522                 ret_ref |= 1;
1523         }
1524         return ret_ref;
1525 }
1526
1527 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1528 CHECK(owner->result_ok);
1529         return ShutdownScript_clone(&*owner->contents.result);
1530 }
1531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1532         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1533         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1534         int64_t ret_ref = 0;
1535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1538         ret_ref = (uintptr_t)ret_var.inner;
1539         if (ret_var.is_owned) {
1540                 ret_ref |= 1;
1541         }
1542         return ret_ref;
1543 }
1544
1545 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1546 CHECK(!owner->result_ok);
1547         return InvalidShutdownScript_clone(&*owner->contents.err);
1548 }
1549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1550         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
1551         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1552         int64_t ret_ref = 0;
1553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1556         ret_ref = (uintptr_t)ret_var.inner;
1557         if (ret_var.is_owned) {
1558                 ret_ref |= 1;
1559         }
1560         return ret_ref;
1561 }
1562
1563 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1564 CHECK(owner->result_ok);
1565         return *owner->contents.result;
1566 }
1567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1568         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1569         CResult_NoneErrorZ_get_ok(owner_conv);
1570 }
1571
1572 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
1573 CHECK(!owner->result_ok);
1574         return *owner->contents.err;
1575 }
1576 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1577         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
1578         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
1579         return ret_conv;
1580 }
1581
1582 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1583 CHECK(owner->result_ok);
1584         return RouteHop_clone(&*owner->contents.result);
1585 }
1586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1587         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1588         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
1589         int64_t ret_ref = 0;
1590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1593         ret_ref = (uintptr_t)ret_var.inner;
1594         if (ret_var.is_owned) {
1595                 ret_ref |= 1;
1596         }
1597         return ret_ref;
1598 }
1599
1600 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1601 CHECK(!owner->result_ok);
1602         return DecodeError_clone(&*owner->contents.err);
1603 }
1604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1605         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1606         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1607         int64_t ret_ref = 0;
1608         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1609         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1611         ret_ref = (uintptr_t)ret_var.inner;
1612         if (ret_var.is_owned) {
1613                 ret_ref |= 1;
1614         }
1615         return ret_ref;
1616 }
1617
1618 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1619         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1620         for (size_t i = 0; i < ret.datalen; i++) {
1621                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1622         }
1623         return ret;
1624 }
1625 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1626         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1627         for (size_t i = 0; i < ret.datalen; i++) {
1628                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1629         }
1630         return ret;
1631 }
1632 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1633 CHECK(owner->result_ok);
1634         return Route_clone(&*owner->contents.result);
1635 }
1636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1637         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1638         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1639         int64_t ret_ref = 0;
1640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1643         ret_ref = (uintptr_t)ret_var.inner;
1644         if (ret_var.is_owned) {
1645                 ret_ref |= 1;
1646         }
1647         return ret_ref;
1648 }
1649
1650 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1651 CHECK(!owner->result_ok);
1652         return DecodeError_clone(&*owner->contents.err);
1653 }
1654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1655         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1656         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1657         int64_t ret_ref = 0;
1658         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1659         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1661         ret_ref = (uintptr_t)ret_var.inner;
1662         if (ret_var.is_owned) {
1663                 ret_ref |= 1;
1664         }
1665         return ret_ref;
1666 }
1667
1668 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1669 CHECK(owner->result_ok);
1670         return RouteParameters_clone(&*owner->contents.result);
1671 }
1672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1673         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1674         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1675         int64_t ret_ref = 0;
1676         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1677         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1679         ret_ref = (uintptr_t)ret_var.inner;
1680         if (ret_var.is_owned) {
1681                 ret_ref |= 1;
1682         }
1683         return ret_ref;
1684 }
1685
1686 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1687 CHECK(!owner->result_ok);
1688         return DecodeError_clone(&*owner->contents.err);
1689 }
1690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1691         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1692         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1693         int64_t ret_ref = 0;
1694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1697         ret_ref = (uintptr_t)ret_var.inner;
1698         if (ret_var.is_owned) {
1699                 ret_ref |= 1;
1700         }
1701         return ret_ref;
1702 }
1703
1704 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1705         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1706         for (size_t i = 0; i < ret.datalen; i++) {
1707                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1708         }
1709         return ret;
1710 }
1711 static jclass LDKCOption_u64Z_Some_class = NULL;
1712 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1713 static jclass LDKCOption_u64Z_None_class = NULL;
1714 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1716         LDKCOption_u64Z_Some_class =
1717                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
1718         CHECK(LDKCOption_u64Z_Some_class != NULL);
1719         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1720         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1721         LDKCOption_u64Z_None_class =
1722                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
1723         CHECK(LDKCOption_u64Z_None_class != NULL);
1724         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1725         CHECK(LDKCOption_u64Z_None_meth != NULL);
1726 }
1727 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1728         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1729         switch(obj->tag) {
1730                 case LDKCOption_u64Z_Some: {
1731                         int64_t some_conv = obj->some;
1732                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
1733                 }
1734                 case LDKCOption_u64Z_None: {
1735                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1736                 }
1737                 default: abort();
1738         }
1739 }
1740 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1741 CHECK(owner->result_ok);
1742         return PaymentParameters_clone(&*owner->contents.result);
1743 }
1744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1745         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1746         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1747         int64_t ret_ref = 0;
1748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1751         ret_ref = (uintptr_t)ret_var.inner;
1752         if (ret_var.is_owned) {
1753                 ret_ref |= 1;
1754         }
1755         return ret_ref;
1756 }
1757
1758 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1759 CHECK(!owner->result_ok);
1760         return DecodeError_clone(&*owner->contents.err);
1761 }
1762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1763         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1764         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1765         int64_t ret_ref = 0;
1766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1769         ret_ref = (uintptr_t)ret_var.inner;
1770         if (ret_var.is_owned) {
1771                 ret_ref |= 1;
1772         }
1773         return ret_ref;
1774 }
1775
1776 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1777         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1778         for (size_t i = 0; i < ret.datalen; i++) {
1779                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1780         }
1781         return ret;
1782 }
1783 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1784 CHECK(owner->result_ok);
1785         return RouteHint_clone(&*owner->contents.result);
1786 }
1787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1788         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1789         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1790         int64_t ret_ref = 0;
1791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1794         ret_ref = (uintptr_t)ret_var.inner;
1795         if (ret_var.is_owned) {
1796                 ret_ref |= 1;
1797         }
1798         return ret_ref;
1799 }
1800
1801 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1802 CHECK(!owner->result_ok);
1803         return DecodeError_clone(&*owner->contents.err);
1804 }
1805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1806         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1807         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1808         int64_t ret_ref = 0;
1809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1812         ret_ref = (uintptr_t)ret_var.inner;
1813         if (ret_var.is_owned) {
1814                 ret_ref |= 1;
1815         }
1816         return ret_ref;
1817 }
1818
1819 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1820 CHECK(owner->result_ok);
1821         return RouteHintHop_clone(&*owner->contents.result);
1822 }
1823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1824         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1825         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1826         int64_t ret_ref = 0;
1827         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1828         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1830         ret_ref = (uintptr_t)ret_var.inner;
1831         if (ret_var.is_owned) {
1832                 ret_ref |= 1;
1833         }
1834         return ret_ref;
1835 }
1836
1837 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1838 CHECK(!owner->result_ok);
1839         return DecodeError_clone(&*owner->contents.err);
1840 }
1841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1842         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1843         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1844         int64_t ret_ref = 0;
1845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1848         ret_ref = (uintptr_t)ret_var.inner;
1849         if (ret_var.is_owned) {
1850                 ret_ref |= 1;
1851         }
1852         return ret_ref;
1853 }
1854
1855 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1856         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1857         for (size_t i = 0; i < ret.datalen; i++) {
1858                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1859         }
1860         return ret;
1861 }
1862 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1863 CHECK(owner->result_ok);
1864         return Route_clone(&*owner->contents.result);
1865 }
1866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1867         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1868         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1869         int64_t ret_ref = 0;
1870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1873         ret_ref = (uintptr_t)ret_var.inner;
1874         if (ret_var.is_owned) {
1875                 ret_ref |= 1;
1876         }
1877         return ret_ref;
1878 }
1879
1880 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1881 CHECK(!owner->result_ok);
1882         return LightningError_clone(&*owner->contents.err);
1883 }
1884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1885         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1886         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1887         int64_t ret_ref = 0;
1888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1891         ret_ref = (uintptr_t)ret_var.inner;
1892         if (ret_var.is_owned) {
1893                 ret_ref |= 1;
1894         }
1895         return ret_ref;
1896 }
1897
1898 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1899 CHECK(owner->result_ok);
1900         return TxOut_clone(&*owner->contents.result);
1901 }
1902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1903         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1904         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1905         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1906         return (int64_t)ret_ref;
1907 }
1908
1909 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1910 CHECK(!owner->result_ok);
1911         return AccessError_clone(&*owner->contents.err);
1912 }
1913 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1914         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1915         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
1916         return ret_conv;
1917 }
1918
1919 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1920         return owner->a;
1921 }
1922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
1923         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1924         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1925         return ret_conv;
1926 }
1927
1928 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1929         return owner->b;
1930 }
1931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
1932         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1933         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1934         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1935         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1936         return ret_arr;
1937 }
1938
1939 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1940         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1941         for (size_t i = 0; i < ret.datalen; i++) {
1942                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1943         }
1944         return ret;
1945 }
1946 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
1947         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1948         for (size_t i = 0; i < ret.datalen; i++) {
1949                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1950         }
1951         return ret;
1952 }
1953 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1954 CHECK(owner->result_ok);
1955         return *owner->contents.result;
1956 }
1957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1958         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1959         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1960 }
1961
1962 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1963 CHECK(!owner->result_ok);
1964         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1965 }
1966 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1967         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1968         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1969         return ret_conv;
1970 }
1971
1972 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1973 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1974 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1975 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1976 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
1977 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
1978 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
1979 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
1980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1981         LDKMonitorEvent_HTLCEvent_class =
1982                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
1983         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1984         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1985         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1986         LDKMonitorEvent_CommitmentTxConfirmed_class =
1987                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
1988         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1989         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1990         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1991         LDKMonitorEvent_UpdateCompleted_class =
1992                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
1993         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
1994         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
1995         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
1996         LDKMonitorEvent_UpdateFailed_class =
1997                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
1998         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
1999         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
2000         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
2001 }
2002 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2003         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2004         switch(obj->tag) {
2005                 case LDKMonitorEvent_HTLCEvent: {
2006                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2007                         int64_t htlc_event_ref = 0;
2008                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2009                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2010                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2011                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
2012                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
2013                 }
2014                 case LDKMonitorEvent_CommitmentTxConfirmed: {
2015                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2016                         int64_t commitment_tx_confirmed_ref = 0;
2017                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2018                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2019                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2020                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
2021                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
2022                 }
2023                 case LDKMonitorEvent_UpdateCompleted: {
2024                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
2025                         int64_t funding_txo_ref = 0;
2026                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2027                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2028                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2029                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
2030                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
2031                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, monitor_update_id_conv);
2032                 }
2033                 case LDKMonitorEvent_UpdateFailed: {
2034                         LDKOutPoint update_failed_var = obj->update_failed;
2035                         int64_t update_failed_ref = 0;
2036                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2037                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2038                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2039                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
2040                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
2041                 }
2042                 default: abort();
2043         }
2044 }
2045 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2046         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2047         for (size_t i = 0; i < ret.datalen; i++) {
2048                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2049         }
2050         return ret;
2051 }
2052 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
2053 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
2054 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
2055 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
2056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
2057         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
2058                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some"));
2059         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
2060         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
2061         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
2062         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
2063                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None"));
2064         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
2065         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
2066         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
2067 }
2068 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2069         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2070         switch(obj->tag) {
2071                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
2072                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
2073                         *some_conv = obj->some;
2074                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
2075                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((int64_t)some_conv));
2076                 }
2077                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
2078                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
2079                 }
2080                 default: abort();
2081         }
2082 }
2083 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
2084 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
2085 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
2086 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
2087 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
2088 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
2089 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
2090 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
2091 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
2092 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
2093 static jclass LDKClosureReason_ProcessingError_class = NULL;
2094 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
2095 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
2096 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
2097 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
2098 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
2099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
2100         LDKClosureReason_CounterpartyForceClosed_class =
2101                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2102         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2103         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2104         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2105         LDKClosureReason_HolderForceClosed_class =
2106                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2107         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2108         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2109         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2110         LDKClosureReason_CooperativeClosure_class =
2111                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2112         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2113         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2114         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2115         LDKClosureReason_CommitmentTxConfirmed_class =
2116                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2117         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2118         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2119         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2120         LDKClosureReason_FundingTimedOut_class =
2121                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2122         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2123         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2124         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2125         LDKClosureReason_ProcessingError_class =
2126                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2127         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2128         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2129         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2130         LDKClosureReason_DisconnectedPeer_class =
2131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2132         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2133         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2134         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2135         LDKClosureReason_OutdatedChannelManager_class =
2136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2137         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2138         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2139         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2140 }
2141 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2142         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
2143         switch(obj->tag) {
2144                 case LDKClosureReason_CounterpartyForceClosed: {
2145                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2146                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2147                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2148                 }
2149                 case LDKClosureReason_HolderForceClosed: {
2150                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2151                 }
2152                 case LDKClosureReason_CooperativeClosure: {
2153                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2154                 }
2155                 case LDKClosureReason_CommitmentTxConfirmed: {
2156                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2157                 }
2158                 case LDKClosureReason_FundingTimedOut: {
2159                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2160                 }
2161                 case LDKClosureReason_ProcessingError: {
2162                         LDKStr err_str = obj->processing_error.err;
2163                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2164                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2165                 }
2166                 case LDKClosureReason_DisconnectedPeer: {
2167                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2168                 }
2169                 case LDKClosureReason_OutdatedChannelManager: {
2170                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2171                 }
2172                 default: abort();
2173         }
2174 }
2175 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2176 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2177 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2178 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2180         LDKCOption_ClosureReasonZ_Some_class =
2181                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2182         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2183         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2184         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2185         LDKCOption_ClosureReasonZ_None_class =
2186                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2187         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2188         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2189         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2190 }
2191 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2192         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
2193         switch(obj->tag) {
2194                 case LDKCOption_ClosureReasonZ_Some: {
2195                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2196                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2197                 }
2198                 case LDKCOption_ClosureReasonZ_None: {
2199                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2200                 }
2201                 default: abort();
2202         }
2203 }
2204 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2205 CHECK(owner->result_ok);
2206         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2207 }
2208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2209         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2210         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2211         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2212         int64_t ret_ref = (uintptr_t)ret_copy;
2213         return ret_ref;
2214 }
2215
2216 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2217 CHECK(!owner->result_ok);
2218         return DecodeError_clone(&*owner->contents.err);
2219 }
2220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2221         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
2222         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2223         int64_t ret_ref = 0;
2224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2227         ret_ref = (uintptr_t)ret_var.inner;
2228         if (ret_var.is_owned) {
2229                 ret_ref |= 1;
2230         }
2231         return ret_ref;
2232 }
2233
2234 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2235 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2236 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
2237 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
2238 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2239 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2241         LDKNetworkUpdate_ChannelUpdateMessage_class =
2242                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2243         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2244         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2245         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2246         LDKNetworkUpdate_ChannelClosed_class =
2247                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed"));
2248         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
2249         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
2250         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
2251         LDKNetworkUpdate_NodeFailure_class =
2252                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2253         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2254         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2255         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2256 }
2257 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2258         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
2259         switch(obj->tag) {
2260                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2261                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2262                         int64_t msg_ref = 0;
2263                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2264                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2265                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2266                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2267                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2268                 }
2269                 case LDKNetworkUpdate_ChannelClosed: {
2270                         int64_t short_channel_id_conv = obj->channel_closed.short_channel_id;
2271                         jboolean is_permanent_conv = obj->channel_closed.is_permanent;
2272                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, short_channel_id_conv, is_permanent_conv);
2273                 }
2274                 case LDKNetworkUpdate_NodeFailure: {
2275                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2276                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2277                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2278                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2279                 }
2280                 default: abort();
2281         }
2282 }
2283 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2284 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2285 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2286 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2288         LDKCOption_NetworkUpdateZ_Some_class =
2289                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2290         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2291         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2292         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2293         LDKCOption_NetworkUpdateZ_None_class =
2294                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2295         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2296         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2297         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2298 }
2299 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2300         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
2301         switch(obj->tag) {
2302                 case LDKCOption_NetworkUpdateZ_Some: {
2303                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2304                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2305                 }
2306                 case LDKCOption_NetworkUpdateZ_None: {
2307                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2308                 }
2309                 default: abort();
2310         }
2311 }
2312 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2313 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2314 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2315 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2316 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2317 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2319         LDKSpendableOutputDescriptor_StaticOutput_class =
2320                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2321         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2322         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2323         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2324         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2325                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2326         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2327         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2328         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2329         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2330                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2331         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2332         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2333         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2334 }
2335 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2336         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
2337         switch(obj->tag) {
2338                 case LDKSpendableOutputDescriptor_StaticOutput: {
2339                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2340                         int64_t outpoint_ref = 0;
2341                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2342                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2343                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2344                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
2345                         int64_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
2346                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (int64_t)output_ref);
2347                 }
2348                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2349                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2350                         int64_t delayed_payment_output_ref = 0;
2351                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2352                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2353                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2354                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
2355                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2356                 }
2357                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2358                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2359                         int64_t static_payment_output_ref = 0;
2360                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2361                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2362                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2363                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
2364                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2365                 }
2366                 default: abort();
2367         }
2368 }
2369 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2370         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2371         for (size_t i = 0; i < ret.datalen; i++) {
2372                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2373         }
2374         return ret;
2375 }
2376 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2377 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2378 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2379 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2381         LDKPaymentPurpose_InvoicePayment_class =
2382                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2383         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2384         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2385         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2386         LDKPaymentPurpose_SpontaneousPayment_class =
2387                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2388         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2389         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2390         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2391 }
2392 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2393         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
2394         switch(obj->tag) {
2395                 case LDKPaymentPurpose_InvoicePayment: {
2396                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2397                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2398                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2399                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2400                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2401                 }
2402                 case LDKPaymentPurpose_SpontaneousPayment: {
2403                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2404                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2405                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2406                 }
2407                 default: abort();
2408         }
2409 }
2410 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2411 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2412 static jclass LDKEvent_PaymentReceived_class = NULL;
2413 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2414 static jclass LDKEvent_PaymentSent_class = NULL;
2415 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2416 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2417 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2418 static jclass LDKEvent_PaymentFailed_class = NULL;
2419 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2420 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2421 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2422 static jclass LDKEvent_SpendableOutputs_class = NULL;
2423 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2424 static jclass LDKEvent_PaymentForwarded_class = NULL;
2425 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2426 static jclass LDKEvent_ChannelClosed_class = NULL;
2427 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2428 static jclass LDKEvent_DiscardFunding_class = NULL;
2429 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
2430 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2431 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2432 static jclass LDKEvent_OpenChannelRequest_class = NULL;
2433 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
2434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
2435         LDKEvent_FundingGenerationReady_class =
2436                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
2437         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
2438         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
2439         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
2440         LDKEvent_PaymentReceived_class =
2441                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
2442         CHECK(LDKEvent_PaymentReceived_class != NULL);
2443         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
2444         CHECK(LDKEvent_PaymentReceived_meth != NULL);
2445         LDKEvent_PaymentSent_class =
2446                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
2447         CHECK(LDKEvent_PaymentSent_class != NULL);
2448         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
2449         CHECK(LDKEvent_PaymentSent_meth != NULL);
2450         LDKEvent_PaymentPathFailed_class =
2451                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
2452         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
2453         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
2454         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
2455         LDKEvent_PaymentFailed_class =
2456                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
2457         CHECK(LDKEvent_PaymentFailed_class != NULL);
2458         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
2459         CHECK(LDKEvent_PaymentFailed_meth != NULL);
2460         LDKEvent_PendingHTLCsForwardable_class =
2461                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
2462         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
2463         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
2464         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
2465         LDKEvent_SpendableOutputs_class =
2466                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
2467         CHECK(LDKEvent_SpendableOutputs_class != NULL);
2468         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
2469         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
2470         LDKEvent_PaymentForwarded_class =
2471                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
2472         CHECK(LDKEvent_PaymentForwarded_class != NULL);
2473         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
2474         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
2475         LDKEvent_ChannelClosed_class =
2476                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
2477         CHECK(LDKEvent_ChannelClosed_class != NULL);
2478         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
2479         CHECK(LDKEvent_ChannelClosed_meth != NULL);
2480         LDKEvent_DiscardFunding_class =
2481                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
2482         CHECK(LDKEvent_DiscardFunding_class != NULL);
2483         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
2484         CHECK(LDKEvent_DiscardFunding_meth != NULL);
2485         LDKEvent_PaymentPathSuccessful_class =
2486                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
2487         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
2488         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
2489         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
2490         LDKEvent_OpenChannelRequest_class =
2491                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
2492         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
2493         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
2494         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
2495 }
2496 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2497         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
2498         switch(obj->tag) {
2499                 case LDKEvent_FundingGenerationReady: {
2500                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2501                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
2502                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
2503                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
2504                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
2505                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
2506                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
2507                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, channel_value_satoshis_conv, output_script_arr, user_channel_id_conv);
2508                 }
2509                 case LDKEvent_PaymentReceived: {
2510                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2511                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
2512                         int64_t amt_conv = obj->payment_received.amt;
2513                         int64_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
2514                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amt_conv, purpose_ref);
2515                 }
2516                 case LDKEvent_PaymentSent: {
2517                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2518                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
2519                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2520                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
2521                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2522                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
2523                         int64_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
2524                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
2525                 }
2526                 case LDKEvent_PaymentPathFailed: {
2527                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2528                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
2529                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2530                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
2531                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
2532                         int64_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
2533                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
2534                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
2535                         int64_tArray path_arr = NULL;
2536                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2537                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2538                         for (size_t k = 0; k < path_var.datalen; k++) {
2539                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2540                                 int64_t path_conv_10_ref = 0;
2541                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2542                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2543                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2544                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2545                                 path_arr_ptr[k] = path_conv_10_ref;
2546                         }
2547                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2548                         int64_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
2549                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
2550                         int64_t retry_ref = 0;
2551                         if ((uintptr_t)retry_var.inner > 4096) {
2552                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2553                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2554                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
2555                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
2556                         }
2557                         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);
2558                 }
2559                 case LDKEvent_PaymentFailed: {
2560                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2561                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
2562                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2563                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
2564                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
2565                 }
2566                 case LDKEvent_PendingHTLCsForwardable: {
2567                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
2568                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
2569                 }
2570                 case LDKEvent_SpendableOutputs: {
2571                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
2572                         int64_tArray outputs_arr = NULL;
2573                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
2574                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
2575                         for (size_t b = 0; b < outputs_var.datalen; b++) {
2576                                 int64_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
2577                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
2578                         }
2579                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
2580                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
2581                 }
2582                 case LDKEvent_PaymentForwarded: {
2583                         int64_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
2584                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
2585                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, claim_from_onchain_tx_conv);
2586                 }
2587                 case LDKEvent_ChannelClosed: {
2588                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2589                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
2590                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
2591                         int64_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
2592                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
2593                 }
2594                 case LDKEvent_DiscardFunding: {
2595                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2596                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
2597                         LDKTransaction transaction_var = obj->discard_funding.transaction;
2598                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
2599                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
2600                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
2601                 }
2602                 case LDKEvent_PaymentPathSuccessful: {
2603                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
2604                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
2605                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2606                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
2607                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
2608                         int64_tArray path_arr = NULL;
2609                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
2610                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
2611                         for (size_t k = 0; k < path_var.datalen; k++) {
2612                                 LDKRouteHop path_conv_10_var = path_var.data[k];
2613                                 int64_t path_conv_10_ref = 0;
2614                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2615                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2616                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
2617                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
2618                                 path_arr_ptr[k] = path_conv_10_ref;
2619                         }
2620                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
2621                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
2622                 }
2623                 case LDKEvent_OpenChannelRequest: {
2624                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
2625                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
2626                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
2627                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
2628                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
2629                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
2630                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
2631                         int64_t channel_type_ref = 0;
2632                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2633                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2634                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
2635                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
2636                         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);
2637                 }
2638                 default: abort();
2639         }
2640 }
2641 static jclass LDKCOption_EventZ_Some_class = NULL;
2642 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
2643 static jclass LDKCOption_EventZ_None_class = NULL;
2644 static jmethodID LDKCOption_EventZ_None_meth = NULL;
2645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
2646         LDKCOption_EventZ_Some_class =
2647                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
2648         CHECK(LDKCOption_EventZ_Some_class != NULL);
2649         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
2650         CHECK(LDKCOption_EventZ_Some_meth != NULL);
2651         LDKCOption_EventZ_None_class =
2652                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
2653         CHECK(LDKCOption_EventZ_None_class != NULL);
2654         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
2655         CHECK(LDKCOption_EventZ_None_meth != NULL);
2656 }
2657 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2658         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
2659         switch(obj->tag) {
2660                 case LDKCOption_EventZ_Some: {
2661                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
2662                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
2663                 }
2664                 case LDKCOption_EventZ_None: {
2665                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
2666                 }
2667                 default: abort();
2668         }
2669 }
2670 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2671 CHECK(owner->result_ok);
2672         return COption_EventZ_clone(&*owner->contents.result);
2673 }
2674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2675         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2676         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
2677         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
2678         int64_t ret_ref = (uintptr_t)ret_copy;
2679         return ret_ref;
2680 }
2681
2682 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
2683 CHECK(!owner->result_ok);
2684         return DecodeError_clone(&*owner->contents.err);
2685 }
2686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2687         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
2688         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
2689         int64_t ret_ref = 0;
2690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2693         ret_ref = (uintptr_t)ret_var.inner;
2694         if (ret_var.is_owned) {
2695                 ret_ref |= 1;
2696         }
2697         return ret_ref;
2698 }
2699
2700 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
2701 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
2702 static jclass LDKErrorAction_IgnoreError_class = NULL;
2703 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
2704 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
2705 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
2706 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
2707 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
2708 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
2709 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2710 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
2711 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
2712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2713         LDKErrorAction_DisconnectPeer_class =
2714                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
2715         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2716         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2717         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2718         LDKErrorAction_IgnoreError_class =
2719                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
2720         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2721         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2722         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2723         LDKErrorAction_IgnoreAndLog_class =
2724                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
2725         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2726         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2727         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2728         LDKErrorAction_IgnoreDuplicateGossip_class =
2729                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
2730         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
2731         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
2732         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
2733         LDKErrorAction_SendErrorMessage_class =
2734                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
2735         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2736         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2737         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2738         LDKErrorAction_SendWarningMessage_class =
2739                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
2740         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
2741         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
2742         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
2743 }
2744 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2745         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2746         switch(obj->tag) {
2747                 case LDKErrorAction_DisconnectPeer: {
2748                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2749                         int64_t msg_ref = 0;
2750                         if ((uintptr_t)msg_var.inner > 4096) {
2751                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2752                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2753                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2754                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2755                         }
2756                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2757                 }
2758                 case LDKErrorAction_IgnoreError: {
2759                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2760                 }
2761                 case LDKErrorAction_IgnoreAndLog: {
2762                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2763                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2764                 }
2765                 case LDKErrorAction_IgnoreDuplicateGossip: {
2766                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
2767                 }
2768                 case LDKErrorAction_SendErrorMessage: {
2769                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2770                         int64_t msg_ref = 0;
2771                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2772                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2773                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2774                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2775                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2776                 }
2777                 case LDKErrorAction_SendWarningMessage: {
2778                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2779                         int64_t msg_ref = 0;
2780                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2781                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2782                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2783                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2784                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
2785                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
2786                 }
2787                 default: abort();
2788         }
2789 }
2790 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2791 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2792 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2793 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2794 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2795 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2796 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2797 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2798 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
2799 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
2800 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2801 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2802 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2803 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2804 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2805 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2806 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2807 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2808 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2809 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2810 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2811 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2812 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2813 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2814 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2815 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2816 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2817 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2818 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2819 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2820 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2821 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2822 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2823 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2824 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2825 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2826 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2827 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2828 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
2829 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
2830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2831         LDKMessageSendEvent_SendAcceptChannel_class =
2832                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
2833         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2834         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2835         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2836         LDKMessageSendEvent_SendOpenChannel_class =
2837                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
2838         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2839         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2840         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2841         LDKMessageSendEvent_SendFundingCreated_class =
2842                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
2843         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2844         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2845         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2846         LDKMessageSendEvent_SendFundingSigned_class =
2847                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
2848         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2849         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2850         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2851         LDKMessageSendEvent_SendFundingLocked_class =
2852                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked"));
2853         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
2854         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
2855         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
2856         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2857                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
2858         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2859         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2860         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2861         LDKMessageSendEvent_UpdateHTLCs_class =
2862                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
2863         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2864         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2865         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2866         LDKMessageSendEvent_SendRevokeAndACK_class =
2867                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
2868         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2869         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2870         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2871         LDKMessageSendEvent_SendClosingSigned_class =
2872                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
2873         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2874         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2875         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2876         LDKMessageSendEvent_SendShutdown_class =
2877                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
2878         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2879         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2880         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2881         LDKMessageSendEvent_SendChannelReestablish_class =
2882                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
2883         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2884         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2885         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2886         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2887                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
2888         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2889         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2890         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2891         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2892                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement"));
2893         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2894         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2895         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2896         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2897                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
2898         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2899         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2900         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2901         LDKMessageSendEvent_SendChannelUpdate_class =
2902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
2903         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2904         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2905         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2906         LDKMessageSendEvent_HandleError_class =
2907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
2908         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2909         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2910         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2911         LDKMessageSendEvent_SendChannelRangeQuery_class =
2912                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
2913         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2914         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2915         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2916         LDKMessageSendEvent_SendShortIdsQuery_class =
2917                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
2918         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2919         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2920         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2921         LDKMessageSendEvent_SendReplyChannelRange_class =
2922                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
2923         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2924         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2925         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2926         LDKMessageSendEvent_SendGossipTimestampFilter_class =
2927                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
2928         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
2929         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
2930         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
2931 }
2932 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2933         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2934         switch(obj->tag) {
2935                 case LDKMessageSendEvent_SendAcceptChannel: {
2936                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2937                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2938                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2939                         int64_t msg_ref = 0;
2940                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2941                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2942                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2943                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2944                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2945                 }
2946                 case LDKMessageSendEvent_SendOpenChannel: {
2947                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2948                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2949                         LDKOpenChannel msg_var = obj->send_open_channel.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_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2956                 }
2957                 case LDKMessageSendEvent_SendFundingCreated: {
2958                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2959                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2960                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2961                         int64_t msg_ref = 0;
2962                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2963                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2964                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2965                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2966                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2967                 }
2968                 case LDKMessageSendEvent_SendFundingSigned: {
2969                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2970                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2971                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2972                         int64_t msg_ref = 0;
2973                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2974                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2975                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2976                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2977                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2978                 }
2979                 case LDKMessageSendEvent_SendFundingLocked: {
2980                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2981                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2982                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2983                         int64_t msg_ref = 0;
2984                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2985                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2986                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2987                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2988                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2989                 }
2990                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2991                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2992                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2993                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2994                         int64_t msg_ref = 0;
2995                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2996                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2997                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2998                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2999                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
3000                 }
3001                 case LDKMessageSendEvent_UpdateHTLCs: {
3002                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3003                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
3004                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3005                         int64_t updates_ref = 0;
3006                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3007                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3008                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3009                         updates_ref = (uintptr_t)updates_var.inner & ~1;
3010                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
3011                 }
3012                 case LDKMessageSendEvent_SendRevokeAndACK: {
3013                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3014                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
3015                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3016                         int64_t msg_ref = 0;
3017                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3018                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3019                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3020                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3021                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
3022                 }
3023                 case LDKMessageSendEvent_SendClosingSigned: {
3024                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3025                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
3026                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3027                         int64_t msg_ref = 0;
3028                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3029                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3030                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3031                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3032                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
3033                 }
3034                 case LDKMessageSendEvent_SendShutdown: {
3035                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3036                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
3037                         LDKShutdown msg_var = obj->send_shutdown.msg;
3038                         int64_t msg_ref = 0;
3039                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3040                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3041                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3042                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3043                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
3044                 }
3045                 case LDKMessageSendEvent_SendChannelReestablish: {
3046                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3047                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
3048                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3049                         int64_t msg_ref = 0;
3050                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3051                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3052                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3053                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3054                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
3055                 }
3056                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
3057                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3058                         int64_t msg_ref = 0;
3059                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3060                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3061                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3062                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3063                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3064                         int64_t update_msg_ref = 0;
3065                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3066                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3067                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3068                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
3069                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
3070                 }
3071                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
3072                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
3073                         int64_t msg_ref = 0;
3074                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3075                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3076                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3077                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3078                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
3079                 }
3080                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
3081                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3082                         int64_t msg_ref = 0;
3083                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3084                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3085                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3086                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3087                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
3088                 }
3089                 case LDKMessageSendEvent_SendChannelUpdate: {
3090                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3091                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
3092                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3093                         int64_t msg_ref = 0;
3094                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3095                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3096                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3097                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3098                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
3099                 }
3100                 case LDKMessageSendEvent_HandleError: {
3101                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3102                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
3103                         int64_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
3104                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
3105                 }
3106                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3107                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3108                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3109                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3110                         int64_t msg_ref = 0;
3111                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3112                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3113                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3114                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3115                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3116                 }
3117                 case LDKMessageSendEvent_SendShortIdsQuery: {
3118                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3119                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3120                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3121                         int64_t msg_ref = 0;
3122                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3123                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3124                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3125                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3126                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3127                 }
3128                 case LDKMessageSendEvent_SendReplyChannelRange: {
3129                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3130                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3131                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3132                         int64_t msg_ref = 0;
3133                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3134                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3135                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3136                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3137                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3138                 }
3139                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3140                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3141                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3142                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3143                         int64_t msg_ref = 0;
3144                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3145                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3146                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3147                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3148                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3149                 }
3150                 default: abort();
3151         }
3152 }
3153 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3154         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3155         for (size_t i = 0; i < ret.datalen; i++) {
3156                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3157         }
3158         return ret;
3159 }
3160 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3161 CHECK(owner->result_ok);
3162         return FixedPenaltyScorer_clone(&*owner->contents.result);
3163 }
3164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3165         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3166         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3167         int64_t ret_ref = 0;
3168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3171         ret_ref = (uintptr_t)ret_var.inner;
3172         if (ret_var.is_owned) {
3173                 ret_ref |= 1;
3174         }
3175         return ret_ref;
3176 }
3177
3178 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3179 CHECK(!owner->result_ok);
3180         return DecodeError_clone(&*owner->contents.err);
3181 }
3182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3183         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
3184         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3185         int64_t ret_ref = 0;
3186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3189         ret_ref = (uintptr_t)ret_var.inner;
3190         if (ret_var.is_owned) {
3191                 ret_ref |= 1;
3192         }
3193         return ret_ref;
3194 }
3195
3196 static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3197 CHECK(owner->result_ok);
3198         return ScoringParameters_clone(&*owner->contents.result);
3199 }
3200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3201         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
3202         LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
3203         int64_t ret_ref = 0;
3204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3207         ret_ref = (uintptr_t)ret_var.inner;
3208         if (ret_var.is_owned) {
3209                 ret_ref |= 1;
3210         }
3211         return ret_ref;
3212 }
3213
3214 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
3215 CHECK(!owner->result_ok);
3216         return DecodeError_clone(&*owner->contents.err);
3217 }
3218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3219         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
3220         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
3221         int64_t ret_ref = 0;
3222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3225         ret_ref = (uintptr_t)ret_var.inner;
3226         if (ret_var.is_owned) {
3227                 ret_ref |= 1;
3228         }
3229         return ret_ref;
3230 }
3231
3232 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
3233 CHECK(owner->result_ok);
3234         return &*owner->contents.result;
3235 }
3236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3237         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
3238         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
3239         int64_t ret_ref = 0;
3240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3243         ret_ref = (uintptr_t)ret_var.inner & ~1;
3244         return ret_ref;
3245 }
3246
3247 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
3248 CHECK(!owner->result_ok);
3249         return DecodeError_clone(&*owner->contents.err);
3250 }
3251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3252         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
3253         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
3254         int64_t ret_ref = 0;
3255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3258         ret_ref = (uintptr_t)ret_var.inner;
3259         if (ret_var.is_owned) {
3260                 ret_ref |= 1;
3261         }
3262         return ret_ref;
3263 }
3264
3265 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3266 CHECK(owner->result_ok);
3267         return &*owner->contents.result;
3268 }
3269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3270         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3271         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3272         int64_t ret_ref = 0;
3273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3276         ret_ref = (uintptr_t)ret_var.inner & ~1;
3277         return ret_ref;
3278 }
3279
3280 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3281 CHECK(!owner->result_ok);
3282         return DecodeError_clone(&*owner->contents.err);
3283 }
3284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3285         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
3286         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3287         int64_t ret_ref = 0;
3288         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3289         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3291         ret_ref = (uintptr_t)ret_var.inner;
3292         if (ret_var.is_owned) {
3293                 ret_ref |= 1;
3294         }
3295         return ret_ref;
3296 }
3297
3298 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3299 CHECK(owner->result_ok);
3300         return InitFeatures_clone(&*owner->contents.result);
3301 }
3302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3303         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3304         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3305         int64_t ret_ref = 0;
3306         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3307         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3309         ret_ref = (uintptr_t)ret_var.inner;
3310         if (ret_var.is_owned) {
3311                 ret_ref |= 1;
3312         }
3313         return ret_ref;
3314 }
3315
3316 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3317 CHECK(!owner->result_ok);
3318         return DecodeError_clone(&*owner->contents.err);
3319 }
3320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3321         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
3322         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3323         int64_t ret_ref = 0;
3324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3327         ret_ref = (uintptr_t)ret_var.inner;
3328         if (ret_var.is_owned) {
3329                 ret_ref |= 1;
3330         }
3331         return ret_ref;
3332 }
3333
3334 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3335 CHECK(owner->result_ok);
3336         return ChannelFeatures_clone(&*owner->contents.result);
3337 }
3338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3339         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3340         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3341         int64_t ret_ref = 0;
3342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3345         ret_ref = (uintptr_t)ret_var.inner;
3346         if (ret_var.is_owned) {
3347                 ret_ref |= 1;
3348         }
3349         return ret_ref;
3350 }
3351
3352 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3353 CHECK(!owner->result_ok);
3354         return DecodeError_clone(&*owner->contents.err);
3355 }
3356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3357         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
3358         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3359         int64_t ret_ref = 0;
3360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3363         ret_ref = (uintptr_t)ret_var.inner;
3364         if (ret_var.is_owned) {
3365                 ret_ref |= 1;
3366         }
3367         return ret_ref;
3368 }
3369
3370 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3371 CHECK(owner->result_ok);
3372         return NodeFeatures_clone(&*owner->contents.result);
3373 }
3374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3375         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3376         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3377         int64_t ret_ref = 0;
3378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3381         ret_ref = (uintptr_t)ret_var.inner;
3382         if (ret_var.is_owned) {
3383                 ret_ref |= 1;
3384         }
3385         return ret_ref;
3386 }
3387
3388 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3389 CHECK(!owner->result_ok);
3390         return DecodeError_clone(&*owner->contents.err);
3391 }
3392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3393         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
3394         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3395         int64_t ret_ref = 0;
3396         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3397         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3399         ret_ref = (uintptr_t)ret_var.inner;
3400         if (ret_var.is_owned) {
3401                 ret_ref |= 1;
3402         }
3403         return ret_ref;
3404 }
3405
3406 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3407 CHECK(owner->result_ok);
3408         return InvoiceFeatures_clone(&*owner->contents.result);
3409 }
3410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3411         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3412         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3413         int64_t ret_ref = 0;
3414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3417         ret_ref = (uintptr_t)ret_var.inner;
3418         if (ret_var.is_owned) {
3419                 ret_ref |= 1;
3420         }
3421         return ret_ref;
3422 }
3423
3424 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3425 CHECK(!owner->result_ok);
3426         return DecodeError_clone(&*owner->contents.err);
3427 }
3428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3429         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
3430         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3431         int64_t ret_ref = 0;
3432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3435         ret_ref = (uintptr_t)ret_var.inner;
3436         if (ret_var.is_owned) {
3437                 ret_ref |= 1;
3438         }
3439         return ret_ref;
3440 }
3441
3442 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3443 CHECK(owner->result_ok);
3444         return ChannelTypeFeatures_clone(&*owner->contents.result);
3445 }
3446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3447         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3448         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3449         int64_t ret_ref = 0;
3450         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3451         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3453         ret_ref = (uintptr_t)ret_var.inner;
3454         if (ret_var.is_owned) {
3455                 ret_ref |= 1;
3456         }
3457         return ret_ref;
3458 }
3459
3460 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3461 CHECK(!owner->result_ok);
3462         return DecodeError_clone(&*owner->contents.err);
3463 }
3464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3465         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
3466         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3467         int64_t ret_ref = 0;
3468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3471         ret_ref = (uintptr_t)ret_var.inner;
3472         if (ret_var.is_owned) {
3473                 ret_ref |= 1;
3474         }
3475         return ret_ref;
3476 }
3477
3478 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3479 CHECK(owner->result_ok);
3480         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3481 }
3482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3483         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3484         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3485         int64_t ret_ref = 0;
3486         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3487         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3489         ret_ref = (uintptr_t)ret_var.inner;
3490         if (ret_var.is_owned) {
3491                 ret_ref |= 1;
3492         }
3493         return ret_ref;
3494 }
3495
3496 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3497 CHECK(!owner->result_ok);
3498         return DecodeError_clone(&*owner->contents.err);
3499 }
3500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3501         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3502         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3503         int64_t ret_ref = 0;
3504         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3505         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3507         ret_ref = (uintptr_t)ret_var.inner;
3508         if (ret_var.is_owned) {
3509                 ret_ref |= 1;
3510         }
3511         return ret_ref;
3512 }
3513
3514 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3515 CHECK(owner->result_ok);
3516         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3517 }
3518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3519         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3520         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3521         int64_t ret_ref = 0;
3522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3525         ret_ref = (uintptr_t)ret_var.inner;
3526         if (ret_var.is_owned) {
3527                 ret_ref |= 1;
3528         }
3529         return ret_ref;
3530 }
3531
3532 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3533 CHECK(!owner->result_ok);
3534         return DecodeError_clone(&*owner->contents.err);
3535 }
3536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3537         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3538         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3539         int64_t ret_ref = 0;
3540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3543         ret_ref = (uintptr_t)ret_var.inner;
3544         if (ret_var.is_owned) {
3545                 ret_ref |= 1;
3546         }
3547         return ret_ref;
3548 }
3549
3550 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3551 CHECK(owner->result_ok);
3552         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3553 }
3554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3555         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3556         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3557         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3558         int64_t ret_ref = (uintptr_t)ret_copy;
3559         return ret_ref;
3560 }
3561
3562 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3563 CHECK(!owner->result_ok);
3564         return DecodeError_clone(&*owner->contents.err);
3565 }
3566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3567         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3568         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3569         int64_t ret_ref = 0;
3570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3573         ret_ref = (uintptr_t)ret_var.inner;
3574         if (ret_var.is_owned) {
3575                 ret_ref |= 1;
3576         }
3577         return ret_ref;
3578 }
3579
3580 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3581         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3582         for (size_t i = 0; i < ret.datalen; i++) {
3583                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3584         }
3585         return ret;
3586 }
3587 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3588         return owner->a;
3589 }
3590 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3591         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3592         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3593         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
3594         return ret_arr;
3595 }
3596
3597 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3598         return owner->b;
3599 }
3600 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3601         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3602         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3603         jobjectArray ret_arr = NULL;
3604         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
3605         ;
3606         for (size_t i = 0; i < ret_var.datalen; i++) {
3607                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
3608                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
3609                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
3610         }
3611         
3612         return ret_arr;
3613 }
3614
3615 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3616 CHECK(owner->result_ok);
3617         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3618 }
3619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3620         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3621         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3622         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3623         return ((int64_t)ret_conv);
3624 }
3625
3626 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3627 CHECK(!owner->result_ok);
3628         return *owner->contents.err;
3629 }
3630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3631         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3632         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3633 }
3634
3635 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3636 CHECK(owner->result_ok);
3637         return *owner->contents.result;
3638 }
3639 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3640         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3641         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3642         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
3643         return ret_arr;
3644 }
3645
3646 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3647 CHECK(!owner->result_ok);
3648         return *owner->contents.err;
3649 }
3650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3651         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3652         CResult_SignatureNoneZ_get_err(owner_conv);
3653 }
3654
3655 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3656         return owner->a;
3657 }
3658 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3659         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3660         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3661         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
3662         return ret_arr;
3663 }
3664
3665 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3666         return owner->b;
3667 }
3668 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3669         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3670         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
3671         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
3672         return ret_arr;
3673 }
3674
3675 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3676 CHECK(owner->result_ok);
3677         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3678 }
3679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3680         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3681         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3682         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3683         return ((int64_t)ret_conv);
3684 }
3685
3686 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3687 CHECK(!owner->result_ok);
3688         return *owner->contents.err;
3689 }
3690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3691         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3692         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3693 }
3694
3695 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3696 CHECK(owner->result_ok);
3697         return *owner->contents.result;
3698 }
3699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3700         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3701         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3702         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
3703         return ret_arr;
3704 }
3705
3706 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3707 CHECK(!owner->result_ok);
3708         return *owner->contents.err;
3709 }
3710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3711         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3712         CResult_SecretKeyNoneZ_get_err(owner_conv);
3713 }
3714
3715 typedef struct LDKBaseSign_JCalls {
3716         atomic_size_t refcnt;
3717         JavaVM *vm;
3718         jweak o;
3719         jmethodID get_per_commitment_point_meth;
3720         jmethodID release_commitment_secret_meth;
3721         jmethodID validate_holder_commitment_meth;
3722         jmethodID channel_keys_id_meth;
3723         jmethodID sign_counterparty_commitment_meth;
3724         jmethodID validate_counterparty_revocation_meth;
3725         jmethodID sign_holder_commitment_and_htlcs_meth;
3726         jmethodID sign_justice_revoked_output_meth;
3727         jmethodID sign_justice_revoked_htlc_meth;
3728         jmethodID sign_counterparty_htlc_transaction_meth;
3729         jmethodID sign_closing_transaction_meth;
3730         jmethodID sign_channel_announcement_meth;
3731         jmethodID ready_channel_meth;
3732 } LDKBaseSign_JCalls;
3733 static void LDKBaseSign_JCalls_free(void* this_arg) {
3734         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3735         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3736                 JNIEnv *env;
3737                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3738                 if (get_jenv_res == JNI_EDETACHED) {
3739                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3740                 } else {
3741                         DO_ASSERT(get_jenv_res == JNI_OK);
3742                 }
3743                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3744                 if (get_jenv_res == JNI_EDETACHED) {
3745                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3746                 }
3747                 FREE(j_calls);
3748         }
3749 }
3750 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3751         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3752         JNIEnv *env;
3753         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3754         if (get_jenv_res == JNI_EDETACHED) {
3755                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3756         } else {
3757                 DO_ASSERT(get_jenv_res == JNI_OK);
3758         }
3759         int64_t idx_conv = idx;
3760         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3761         CHECK(obj != NULL);
3762         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
3763         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3764                 (*env)->ExceptionDescribe(env);
3765                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
3766         }
3767         LDKPublicKey ret_ref;
3768         CHECK((*env)->GetArrayLength(env, ret) == 33);
3769         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
3770         if (get_jenv_res == JNI_EDETACHED) {
3771                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3772         }
3773         return ret_ref;
3774 }
3775 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3776         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3777         JNIEnv *env;
3778         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3779         if (get_jenv_res == JNI_EDETACHED) {
3780                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3781         } else {
3782                 DO_ASSERT(get_jenv_res == JNI_OK);
3783         }
3784         int64_t idx_conv = idx;
3785         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3786         CHECK(obj != NULL);
3787         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
3788         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3789                 (*env)->ExceptionDescribe(env);
3790                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
3791         }
3792         LDKThirtyTwoBytes ret_ref;
3793         CHECK((*env)->GetArrayLength(env, ret) == 32);
3794         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3795         if (get_jenv_res == JNI_EDETACHED) {
3796                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3797         }
3798         return ret_ref;
3799 }
3800 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3801         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3802         JNIEnv *env;
3803         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3804         if (get_jenv_res == JNI_EDETACHED) {
3805                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3806         } else {
3807                 DO_ASSERT(get_jenv_res == JNI_OK);
3808         }
3809         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3810         int64_t holder_tx_ref = 0;
3811         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
3812         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3813         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3814         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3815         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3816         if (holder_tx_var.is_owned) {
3817                 holder_tx_ref |= 1;
3818         }
3819         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3820         jobjectArray preimages_arr = NULL;
3821         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
3822         ;
3823         for (size_t i = 0; i < preimages_var.datalen; i++) {
3824                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
3825                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
3826                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
3827         }
3828         
3829         FREE(preimages_var.data);
3830         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3831         CHECK(obj != NULL);
3832         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
3833         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3834                 (*env)->ExceptionDescribe(env);
3835                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
3836         }
3837         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3838         CHECK_ACCESS(ret_ptr);
3839         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3840         FREE((void*)ret);
3841         if (get_jenv_res == JNI_EDETACHED) {
3842                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3843         }
3844         return ret_conv;
3845 }
3846 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3847         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3848         JNIEnv *env;
3849         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3850         if (get_jenv_res == JNI_EDETACHED) {
3851                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3852         } else {
3853                 DO_ASSERT(get_jenv_res == JNI_OK);
3854         }
3855         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3856         CHECK(obj != NULL);
3857         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
3858         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3859                 (*env)->ExceptionDescribe(env);
3860                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
3861         }
3862         LDKThirtyTwoBytes ret_ref;
3863         CHECK((*env)->GetArrayLength(env, ret) == 32);
3864         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
3865         if (get_jenv_res == JNI_EDETACHED) {
3866                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3867         }
3868         return ret_ref;
3869 }
3870 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3871         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3872         JNIEnv *env;
3873         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3874         if (get_jenv_res == JNI_EDETACHED) {
3875                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3876         } else {
3877                 DO_ASSERT(get_jenv_res == JNI_OK);
3878         }
3879         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3880         int64_t commitment_tx_ref = 0;
3881         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3882         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3883         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3884         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3885         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3886         if (commitment_tx_var.is_owned) {
3887                 commitment_tx_ref |= 1;
3888         }
3889         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3890         jobjectArray preimages_arr = NULL;
3891         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
3892         ;
3893         for (size_t i = 0; i < preimages_var.datalen; i++) {
3894                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
3895                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
3896                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
3897         }
3898         
3899         FREE(preimages_var.data);
3900         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3901         CHECK(obj != NULL);
3902         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
3903         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3904                 (*env)->ExceptionDescribe(env);
3905                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
3906         }
3907         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3908         CHECK_ACCESS(ret_ptr);
3909         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3910         FREE((void*)ret);
3911         if (get_jenv_res == JNI_EDETACHED) {
3912                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3913         }
3914         return ret_conv;
3915 }
3916 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3917         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3918         JNIEnv *env;
3919         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3920         if (get_jenv_res == JNI_EDETACHED) {
3921                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3922         } else {
3923                 DO_ASSERT(get_jenv_res == JNI_OK);
3924         }
3925         int64_t idx_conv = idx;
3926         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
3927         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
3928         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3929         CHECK(obj != NULL);
3930         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
3931         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3932                 (*env)->ExceptionDescribe(env);
3933                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
3934         }
3935         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3936         CHECK_ACCESS(ret_ptr);
3937         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3938         FREE((void*)ret);
3939         if (get_jenv_res == JNI_EDETACHED) {
3940                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3941         }
3942         return ret_conv;
3943 }
3944 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3945         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3946         JNIEnv *env;
3947         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3948         if (get_jenv_res == JNI_EDETACHED) {
3949                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3950         } else {
3951                 DO_ASSERT(get_jenv_res == JNI_OK);
3952         }
3953         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3954         int64_t commitment_tx_ref = 0;
3955         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3956         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3957         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3958         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3959         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3960         if (commitment_tx_var.is_owned) {
3961                 commitment_tx_ref |= 1;
3962         }
3963         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3964         CHECK(obj != NULL);
3965         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
3966         if (UNLIKELY((*env)->ExceptionCheck(env))) {
3967                 (*env)->ExceptionDescribe(env);
3968                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
3969         }
3970         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3971         CHECK_ACCESS(ret_ptr);
3972         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3973         FREE((void*)ret);
3974         if (get_jenv_res == JNI_EDETACHED) {
3975                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3976         }
3977         return ret_conv;
3978 }
3979 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]) {
3980         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3981         JNIEnv *env;
3982         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3983         if (get_jenv_res == JNI_EDETACHED) {
3984                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3985         } else {
3986                 DO_ASSERT(get_jenv_res == JNI_OK);
3987         }
3988         LDKTransaction justice_tx_var = justice_tx;
3989         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
3990         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
3991         Transaction_free(justice_tx_var);
3992         int64_t input_conv = input;
3993         int64_t amount_conv = amount;
3994         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
3995         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
3996         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3997         CHECK(obj != NULL);
3998         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);
3999         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4000                 (*env)->ExceptionDescribe(env);
4001                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
4002         }
4003         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4004         CHECK_ACCESS(ret_ptr);
4005         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4006         FREE((void*)ret);
4007         if (get_jenv_res == JNI_EDETACHED) {
4008                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4009         }
4010         return ret_conv;
4011 }
4012 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) {
4013         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4014         JNIEnv *env;
4015         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4016         if (get_jenv_res == JNI_EDETACHED) {
4017                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4018         } else {
4019                 DO_ASSERT(get_jenv_res == JNI_OK);
4020         }
4021         LDKTransaction justice_tx_var = justice_tx;
4022         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
4023         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
4024         Transaction_free(justice_tx_var);
4025         int64_t input_conv = input;
4026         int64_t amount_conv = amount;
4027         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
4028         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
4029         LDKHTLCOutputInCommitment htlc_var = *htlc;
4030         int64_t htlc_ref = 0;
4031         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4032         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4033         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4034         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4035         htlc_ref = (uintptr_t)htlc_var.inner;
4036         if (htlc_var.is_owned) {
4037                 htlc_ref |= 1;
4038         }
4039         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4040         CHECK(obj != NULL);
4041         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);
4042         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4043                 (*env)->ExceptionDescribe(env);
4044                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
4045         }
4046         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4047         CHECK_ACCESS(ret_ptr);
4048         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4049         FREE((void*)ret);
4050         if (get_jenv_res == JNI_EDETACHED) {
4051                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4052         }
4053         return ret_conv;
4054 }
4055 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) {
4056         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4057         JNIEnv *env;
4058         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4059         if (get_jenv_res == JNI_EDETACHED) {
4060                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4061         } else {
4062                 DO_ASSERT(get_jenv_res == JNI_OK);
4063         }
4064         LDKTransaction htlc_tx_var = htlc_tx;
4065         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
4066         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
4067         Transaction_free(htlc_tx_var);
4068         int64_t input_conv = input;
4069         int64_t amount_conv = amount;
4070         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
4071         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
4072         LDKHTLCOutputInCommitment htlc_var = *htlc;
4073         int64_t htlc_ref = 0;
4074         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
4075         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4076         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4077         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
4078         htlc_ref = (uintptr_t)htlc_var.inner;
4079         if (htlc_var.is_owned) {
4080                 htlc_ref |= 1;
4081         }
4082         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4083         CHECK(obj != NULL);
4084         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);
4085         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4086                 (*env)->ExceptionDescribe(env);
4087                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
4088         }
4089         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4090         CHECK_ACCESS(ret_ptr);
4091         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4092         FREE((void*)ret);
4093         if (get_jenv_res == JNI_EDETACHED) {
4094                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4095         }
4096         return ret_conv;
4097 }
4098 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
4099         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4100         JNIEnv *env;
4101         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4102         if (get_jenv_res == JNI_EDETACHED) {
4103                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4104         } else {
4105                 DO_ASSERT(get_jenv_res == JNI_OK);
4106         }
4107         LDKClosingTransaction closing_tx_var = *closing_tx;
4108         int64_t closing_tx_ref = 0;
4109         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
4110         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4111         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4112         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
4113         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
4114         if (closing_tx_var.is_owned) {
4115                 closing_tx_ref |= 1;
4116         }
4117         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4118         CHECK(obj != NULL);
4119         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
4120         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4121                 (*env)->ExceptionDescribe(env);
4122                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
4123         }
4124         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4125         CHECK_ACCESS(ret_ptr);
4126         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
4127         FREE((void*)ret);
4128         if (get_jenv_res == JNI_EDETACHED) {
4129                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4130         }
4131         return ret_conv;
4132 }
4133 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
4134         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4135         JNIEnv *env;
4136         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4137         if (get_jenv_res == JNI_EDETACHED) {
4138                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4139         } else {
4140                 DO_ASSERT(get_jenv_res == JNI_OK);
4141         }
4142         LDKUnsignedChannelAnnouncement msg_var = *msg;
4143         int64_t msg_ref = 0;
4144         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
4145         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4146         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4147         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4148         msg_ref = (uintptr_t)msg_var.inner;
4149         if (msg_var.is_owned) {
4150                 msg_ref |= 1;
4151         }
4152         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4153         CHECK(obj != NULL);
4154         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
4155         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4156                 (*env)->ExceptionDescribe(env);
4157                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
4158         }
4159         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4160         CHECK_ACCESS(ret_ptr);
4161         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
4162         FREE((void*)ret);
4163         if (get_jenv_res == JNI_EDETACHED) {
4164                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4165         }
4166         return ret_conv;
4167 }
4168 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
4169         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
4170         JNIEnv *env;
4171         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4172         if (get_jenv_res == JNI_EDETACHED) {
4173                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4174         } else {
4175                 DO_ASSERT(get_jenv_res == JNI_OK);
4176         }
4177         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
4178         int64_t channel_parameters_ref = 0;
4179         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
4180         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4181         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4182         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
4183         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
4184         if (channel_parameters_var.is_owned) {
4185                 channel_parameters_ref |= 1;
4186         }
4187         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4188         CHECK(obj != NULL);
4189         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
4190         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4191                 (*env)->ExceptionDescribe(env);
4192                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
4193         }
4194         if (get_jenv_res == JNI_EDETACHED) {
4195                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4196         }
4197 }
4198 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4199         jclass c = (*env)->GetObjectClass(env, o);
4200         CHECK(c != NULL);
4201         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
4202         atomic_init(&calls->refcnt, 1);
4203         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4204         calls->o = (*env)->NewWeakGlobalRef(env, o);
4205         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
4206         CHECK(calls->get_per_commitment_point_meth != NULL);
4207         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
4208         CHECK(calls->release_commitment_secret_meth != NULL);
4209         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
4210         CHECK(calls->validate_holder_commitment_meth != NULL);
4211         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
4212         CHECK(calls->channel_keys_id_meth != NULL);
4213         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
4214         CHECK(calls->sign_counterparty_commitment_meth != NULL);
4215         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
4216         CHECK(calls->validate_counterparty_revocation_meth != NULL);
4217         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
4218         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
4219         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
4220         CHECK(calls->sign_justice_revoked_output_meth != NULL);
4221         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
4222         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
4223         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
4224         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
4225         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
4226         CHECK(calls->sign_closing_transaction_meth != NULL);
4227         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
4228         CHECK(calls->sign_channel_announcement_meth != NULL);
4229         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
4230         CHECK(calls->ready_channel_meth != NULL);
4231
4232         LDKChannelPublicKeys pubkeys_conv;
4233         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4234         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4235         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4236
4237         LDKBaseSign ret = {
4238                 .this_arg = (void*) calls,
4239                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
4240                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
4241                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
4242                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
4243                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
4244                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
4245                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
4246                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
4247                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
4248                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
4249                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
4250                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
4251                 .ready_channel = ready_channel_LDKBaseSign_jcall,
4252                 .free = LDKBaseSign_JCalls_free,
4253                 .pubkeys = pubkeys_conv,
4254                 .set_pubkeys = NULL,
4255         };
4256         return ret;
4257 }
4258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
4259         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
4260         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
4261         return (uint64_t)res_ptr;
4262 }
4263 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) {
4264         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4265         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4266         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4267         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4268         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
4269         return ret_arr;
4270 }
4271
4272 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
4273         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4274         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4275         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4276         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4277         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
4278         return ret_arr;
4279 }
4280
4281 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) {
4282         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4283         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4284         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4285         LDKHolderCommitmentTransaction holder_tx_conv;
4286         holder_tx_conv.inner = (void*)(holder_tx & (~1));
4287         holder_tx_conv.is_owned = false;
4288         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
4289         LDKCVec_PaymentPreimageZ preimages_constr;
4290         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4291         if (preimages_constr.datalen > 0)
4292                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4293         else
4294                 preimages_constr.data = NULL;
4295         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4296                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4297                 LDKThirtyTwoBytes preimages_conv_8_ref;
4298                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4299                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4300                 preimages_constr.data[i] = preimages_conv_8_ref;
4301         }
4302         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4303         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4304         return (int64_t)ret_conv;
4305 }
4306
4307 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
4308         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4309         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4310         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4311         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4312         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
4313         return ret_arr;
4314 }
4315
4316 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) {
4317         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4318         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4319         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4320         LDKCommitmentTransaction commitment_tx_conv;
4321         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4322         commitment_tx_conv.is_owned = false;
4323         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4324         LDKCVec_PaymentPreimageZ preimages_constr;
4325         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
4326         if (preimages_constr.datalen > 0)
4327                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4328         else
4329                 preimages_constr.data = NULL;
4330         for (size_t i = 0; i < preimages_constr.datalen; i++) {
4331                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
4332                 LDKThirtyTwoBytes preimages_conv_8_ref;
4333                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
4334                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
4335                 preimages_constr.data[i] = preimages_conv_8_ref;
4336         }
4337         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4338         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4339         return (int64_t)ret_conv;
4340 }
4341
4342 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) {
4343         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4344         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4345         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4346         unsigned char secret_arr[32];
4347         CHECK((*env)->GetArrayLength(env, secret) == 32);
4348         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
4349         unsigned char (*secret_ref)[32] = &secret_arr;
4350         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4351         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4352         return (int64_t)ret_conv;
4353 }
4354
4355 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) {
4356         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4357         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4358         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4359         LDKHolderCommitmentTransaction commitment_tx_conv;
4360         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4361         commitment_tx_conv.is_owned = false;
4362         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4363         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4364         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4365         return (int64_t)ret_conv;
4366 }
4367
4368 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) {
4369         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4370         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4371         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4372         LDKTransaction justice_tx_ref;
4373         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4374         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4375         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4376         justice_tx_ref.data_is_owned = true;
4377         unsigned char per_commitment_key_arr[32];
4378         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4379         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4380         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4381         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4382         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4383         return (int64_t)ret_conv;
4384 }
4385
4386 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) {
4387         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4388         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4389         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4390         LDKTransaction justice_tx_ref;
4391         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
4392         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4393         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
4394         justice_tx_ref.data_is_owned = true;
4395         unsigned char per_commitment_key_arr[32];
4396         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
4397         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
4398         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4399         LDKHTLCOutputInCommitment htlc_conv;
4400         htlc_conv.inner = (void*)(htlc & (~1));
4401         htlc_conv.is_owned = false;
4402         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4403         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4404         *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);
4405         return (int64_t)ret_conv;
4406 }
4407
4408 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) {
4409         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4410         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4411         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4412         LDKTransaction htlc_tx_ref;
4413         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
4414         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4415         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
4416         htlc_tx_ref.data_is_owned = true;
4417         LDKPublicKey per_commitment_point_ref;
4418         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
4419         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
4420         LDKHTLCOutputInCommitment htlc_conv;
4421         htlc_conv.inner = (void*)(htlc & (~1));
4422         htlc_conv.is_owned = false;
4423         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4424         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4425         *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);
4426         return (int64_t)ret_conv;
4427 }
4428
4429 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) {
4430         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4431         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4432         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4433         LDKClosingTransaction closing_tx_conv;
4434         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4435         closing_tx_conv.is_owned = false;
4436         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4437         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4438         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4439         return (int64_t)ret_conv;
4440 }
4441
4442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
4443         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4444         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4445         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4446         LDKUnsignedChannelAnnouncement msg_conv;
4447         msg_conv.inner = (void*)(msg & (~1));
4448         msg_conv.is_owned = false;
4449         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4450         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4451         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4452         return (int64_t)ret_conv;
4453 }
4454
4455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
4456         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4457         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4458         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4459         LDKChannelTransactionParameters channel_parameters_conv;
4460         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4461         channel_parameters_conv.is_owned = false;
4462         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4463         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4464 }
4465
4466 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4467         if (this_arg->set_pubkeys != NULL)
4468                 this_arg->set_pubkeys(this_arg);
4469         return this_arg->pubkeys;
4470 }
4471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
4472         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4473         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4474         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4475         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4476         int64_t ret_ref = 0;
4477         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4478         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4480         ret_ref = (uintptr_t)ret_var.inner;
4481         if (ret_var.is_owned) {
4482                 ret_ref |= 1;
4483         }
4484         return ret_ref;
4485 }
4486
4487 typedef struct LDKSign_JCalls {
4488         atomic_size_t refcnt;
4489         JavaVM *vm;
4490         jweak o;
4491         LDKBaseSign_JCalls* BaseSign;
4492         jmethodID write_meth;
4493 } LDKSign_JCalls;
4494 static void LDKSign_JCalls_free(void* this_arg) {
4495         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4496         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4497                 JNIEnv *env;
4498                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4499                 if (get_jenv_res == JNI_EDETACHED) {
4500                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4501                 } else {
4502                         DO_ASSERT(get_jenv_res == JNI_OK);
4503                 }
4504                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4505                 if (get_jenv_res == JNI_EDETACHED) {
4506                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4507                 }
4508                 FREE(j_calls);
4509         }
4510 }
4511 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4512         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4513         JNIEnv *env;
4514         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4515         if (get_jenv_res == JNI_EDETACHED) {
4516                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4517         } else {
4518                 DO_ASSERT(get_jenv_res == JNI_OK);
4519         }
4520         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4521         CHECK(obj != NULL);
4522         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
4523         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4524                 (*env)->ExceptionDescribe(env);
4525                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
4526         }
4527         LDKCVec_u8Z ret_ref;
4528         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4529         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4530         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4531         if (get_jenv_res == JNI_EDETACHED) {
4532                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4533         }
4534         return ret_ref;
4535 }
4536 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4537         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4538         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4539         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4540 }
4541 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4542         jclass c = (*env)->GetObjectClass(env, o);
4543         CHECK(c != NULL);
4544         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4545         atomic_init(&calls->refcnt, 1);
4546         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4547         calls->o = (*env)->NewWeakGlobalRef(env, o);
4548         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
4549         CHECK(calls->write_meth != NULL);
4550
4551         LDKChannelPublicKeys pubkeys_conv;
4552         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4553         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4554         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4555
4556         LDKSign ret = {
4557                 .this_arg = (void*) calls,
4558                 .write = write_LDKSign_jcall,
4559                 .cloned = LDKSign_JCalls_cloned,
4560                 .free = LDKSign_JCalls_free,
4561                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
4562         };
4563         calls->BaseSign = ret.BaseSign.this_arg;
4564         return ret;
4565 }
4566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
4567         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4568         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
4569         return (uint64_t)res_ptr;
4570 }
4571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
4572         LDKSign *inp = (LDKSign *)(arg & ~1);
4573         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
4574         DO_ASSERT((res_ptr & 1) == 0);
4575         return (int64_t)(res_ptr | 1);
4576 }
4577 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
4578         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4579         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4580         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4581         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4582         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4583         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4584         CVec_u8Z_free(ret_var);
4585         return ret_arr;
4586 }
4587
4588 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4589 CHECK(owner->result_ok);
4590         return Sign_clone(&*owner->contents.result);
4591 }
4592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4593         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4594         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4595         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4596         return (int64_t)ret_ret;
4597 }
4598
4599 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4600 CHECK(!owner->result_ok);
4601         return DecodeError_clone(&*owner->contents.err);
4602 }
4603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4604         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4605         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4606         int64_t ret_ref = 0;
4607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4610         ret_ref = (uintptr_t)ret_var.inner;
4611         if (ret_var.is_owned) {
4612                 ret_ref |= 1;
4613         }
4614         return ret_ref;
4615 }
4616
4617 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4618 CHECK(owner->result_ok);
4619         return *owner->contents.result;
4620 }
4621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4622         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4623         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
4624         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
4625         return ret_arr;
4626 }
4627
4628 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4629 CHECK(!owner->result_ok);
4630         return *owner->contents.err;
4631 }
4632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4633         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4634         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4635 }
4636
4637 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4638         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4639         for (size_t i = 0; i < ret.datalen; i++) {
4640                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4641         }
4642         return ret;
4643 }
4644 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4645 CHECK(owner->result_ok);
4646         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4647 }
4648 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4649         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4650         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4651         jobjectArray ret_arr = NULL;
4652         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4653         ;
4654         for (size_t i = 0; i < ret_var.datalen; i++) {
4655                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
4656                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
4657                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
4658                 CVec_u8Z_free(ret_conv_8_var);
4659                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
4660         }
4661         
4662         FREE(ret_var.data);
4663         return ret_arr;
4664 }
4665
4666 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4667 CHECK(!owner->result_ok);
4668         return *owner->contents.err;
4669 }
4670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4671         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4672         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4673 }
4674
4675 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4676 CHECK(owner->result_ok);
4677         return InMemorySigner_clone(&*owner->contents.result);
4678 }
4679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4680         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4681         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4682         int64_t ret_ref = 0;
4683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4686         ret_ref = (uintptr_t)ret_var.inner;
4687         if (ret_var.is_owned) {
4688                 ret_ref |= 1;
4689         }
4690         return ret_ref;
4691 }
4692
4693 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4694 CHECK(!owner->result_ok);
4695         return DecodeError_clone(&*owner->contents.err);
4696 }
4697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4698         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4699         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4700         int64_t ret_ref = 0;
4701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4704         ret_ref = (uintptr_t)ret_var.inner;
4705         if (ret_var.is_owned) {
4706                 ret_ref |= 1;
4707         }
4708         return ret_ref;
4709 }
4710
4711 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4712         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4713         for (size_t i = 0; i < ret.datalen; i++) {
4714                 ret.data[i] = TxOut_clone(&orig->data[i]);
4715         }
4716         return ret;
4717 }
4718 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4719 CHECK(owner->result_ok);
4720         return *owner->contents.result;
4721 }
4722 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4723         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4724         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4725         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4726         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4727         return ret_arr;
4728 }
4729
4730 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4731 CHECK(!owner->result_ok);
4732         return *owner->contents.err;
4733 }
4734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4735         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4736         CResult_TransactionNoneZ_get_err(owner_conv);
4737 }
4738
4739 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4740         return ThirtyTwoBytes_clone(&owner->a);
4741 }
4742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4743         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4744         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4745         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
4746         return ret_arr;
4747 }
4748
4749 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
4750         return ChannelMonitor_clone(&owner->b);
4751 }
4752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4753         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
4754         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
4755         int64_t ret_ref = 0;
4756         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4757         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4759         ret_ref = (uintptr_t)ret_var.inner;
4760         if (ret_var.is_owned) {
4761                 ret_ref |= 1;
4762         }
4763         return ret_ref;
4764 }
4765
4766 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
4767         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
4768         for (size_t i = 0; i < ret.datalen; i++) {
4769                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
4770         }
4771         return ret;
4772 }
4773 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4774 CHECK(owner->result_ok);
4775         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
4776 }
4777 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4778         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4779         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
4780         int64_tArray ret_arr = NULL;
4781         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4782         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4783         for (size_t j = 0; j < ret_var.datalen; j++) {
4784                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4785                 *ret_conv_35_conv = ret_var.data[j];
4786                 ret_arr_ptr[j] = ((int64_t)ret_conv_35_conv);
4787         }
4788         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4789         FREE(ret_var.data);
4790         return ret_arr;
4791 }
4792
4793 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
4794 CHECK(!owner->result_ok);
4795         return *owner->contents.err;
4796 }
4797 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4798         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(owner & ~1);
4799         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
4800         return ret_conv;
4801 }
4802
4803 static jclass LDKCOption_u16Z_Some_class = NULL;
4804 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
4805 static jclass LDKCOption_u16Z_None_class = NULL;
4806 static jmethodID LDKCOption_u16Z_None_meth = NULL;
4807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
4808         LDKCOption_u16Z_Some_class =
4809                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
4810         CHECK(LDKCOption_u16Z_Some_class != NULL);
4811         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
4812         CHECK(LDKCOption_u16Z_Some_meth != NULL);
4813         LDKCOption_u16Z_None_class =
4814                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
4815         CHECK(LDKCOption_u16Z_None_class != NULL);
4816         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
4817         CHECK(LDKCOption_u16Z_None_meth != NULL);
4818 }
4819 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4820         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4821         switch(obj->tag) {
4822                 case LDKCOption_u16Z_Some: {
4823                         int16_t some_conv = obj->some;
4824                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
4825                 }
4826                 case LDKCOption_u16Z_None: {
4827                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
4828                 }
4829                 default: abort();
4830         }
4831 }
4832 static jclass LDKAPIError_APIMisuseError_class = NULL;
4833 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
4834 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
4835 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
4836 static jclass LDKAPIError_RouteError_class = NULL;
4837 static jmethodID LDKAPIError_RouteError_meth = NULL;
4838 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
4839 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
4840 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
4841 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
4842 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
4843 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
4844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
4845         LDKAPIError_APIMisuseError_class =
4846                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
4847         CHECK(LDKAPIError_APIMisuseError_class != NULL);
4848         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
4849         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
4850         LDKAPIError_FeeRateTooHigh_class =
4851                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
4852         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
4853         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
4854         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
4855         LDKAPIError_RouteError_class =
4856                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
4857         CHECK(LDKAPIError_RouteError_class != NULL);
4858         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
4859         CHECK(LDKAPIError_RouteError_meth != NULL);
4860         LDKAPIError_ChannelUnavailable_class =
4861                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
4862         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
4863         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
4864         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
4865         LDKAPIError_MonitorUpdateFailed_class =
4866                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
4867         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
4868         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
4869         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
4870         LDKAPIError_IncompatibleShutdownScript_class =
4871                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
4872         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
4873         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
4874         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
4875 }
4876 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4877         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4878         switch(obj->tag) {
4879                 case LDKAPIError_APIMisuseError: {
4880                         LDKStr err_str = obj->api_misuse_error.err;
4881                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4882                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
4883                 }
4884                 case LDKAPIError_FeeRateTooHigh: {
4885                         LDKStr err_str = obj->fee_rate_too_high.err;
4886                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4887                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
4888                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
4889                 }
4890                 case LDKAPIError_RouteError: {
4891                         LDKStr err_str = obj->route_error.err;
4892                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4893                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
4894                 }
4895                 case LDKAPIError_ChannelUnavailable: {
4896                         LDKStr err_str = obj->channel_unavailable.err;
4897                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
4898                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
4899                 }
4900                 case LDKAPIError_MonitorUpdateFailed: {
4901                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
4902                 }
4903                 case LDKAPIError_IncompatibleShutdownScript: {
4904                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4905                         int64_t script_ref = 0;
4906                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4907                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4908                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4909                         script_ref = (uintptr_t)script_var.inner & ~1;
4910                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
4911                 }
4912                 default: abort();
4913         }
4914 }
4915 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4916 CHECK(owner->result_ok);
4917         return *owner->contents.result;
4918 }
4919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4920         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4921         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4922 }
4923
4924 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4925 CHECK(!owner->result_ok);
4926         return APIError_clone(&*owner->contents.err);
4927 }
4928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4929         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4930         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4931         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4932         int64_t ret_ref = (uintptr_t)ret_copy;
4933         return ret_ref;
4934 }
4935
4936 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4937         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4938         for (size_t i = 0; i < ret.datalen; i++) {
4939                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4940         }
4941         return ret;
4942 }
4943 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4944         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4945         for (size_t i = 0; i < ret.datalen; i++) {
4946                 ret.data[i] = APIError_clone(&orig->data[i]);
4947         }
4948         return ret;
4949 }
4950 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4951 CHECK(owner->result_ok);
4952         return ThirtyTwoBytes_clone(&*owner->contents.result);
4953 }
4954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4955         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4956         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
4958         return ret_arr;
4959 }
4960
4961 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4962 CHECK(!owner->result_ok);
4963         return APIError_clone(&*owner->contents.err);
4964 }
4965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4966         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4967         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4968         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4969         int64_t ret_ref = (uintptr_t)ret_copy;
4970         return ret_ref;
4971 }
4972
4973 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
4974 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
4975 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
4976 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
4977 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
4978 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
4979 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
4980 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
4981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
4982         LDKPaymentSendFailure_ParameterError_class =
4983                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
4984         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
4985         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
4986         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
4987         LDKPaymentSendFailure_PathParameterError_class =
4988                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
4989         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
4990         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
4991         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
4992         LDKPaymentSendFailure_AllFailedRetrySafe_class =
4993                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
4994         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
4995         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
4996         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
4997         LDKPaymentSendFailure_PartialFailure_class =
4998                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
4999         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
5000         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
5001         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
5002 }
5003 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5004         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5005         switch(obj->tag) {
5006                 case LDKPaymentSendFailure_ParameterError: {
5007                         int64_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
5008                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
5009                 }
5010                 case LDKPaymentSendFailure_PathParameterError: {
5011                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
5012                         int64_tArray path_parameter_error_arr = NULL;
5013                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
5014                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
5015                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
5016                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5017                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
5018                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
5019                                 path_parameter_error_arr_ptr[w] = (int64_t)path_parameter_error_conv_22_conv;
5020                         }
5021                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
5022                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
5023                 }
5024                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
5025                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
5026                         int64_tArray all_failed_retry_safe_arr = NULL;
5027                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
5028                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
5029                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
5030                                 int64_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
5031                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
5032                         }
5033                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
5034                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
5035                 }
5036                 case LDKPaymentSendFailure_PartialFailure: {
5037                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
5038                         int64_tArray results_arr = NULL;
5039                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
5040                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
5041                         for (size_t w = 0; w < results_var.datalen; w++) {
5042                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5043                                 *results_conv_22_conv = results_var.data[w];
5044                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
5045                                 results_arr_ptr[w] = (int64_t)results_conv_22_conv;
5046                         }
5047                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
5048                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
5049                         int64_t failed_paths_retry_ref = 0;
5050                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
5051                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5052                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5053                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
5054                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
5055                         }
5056                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
5057                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
5058                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
5059                 }
5060                 default: abort();
5061         }
5062 }
5063 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5064 CHECK(owner->result_ok);
5065         return ThirtyTwoBytes_clone(&*owner->contents.result);
5066 }
5067 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5068         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5069         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5070         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
5071         return ret_arr;
5072 }
5073
5074 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
5075 CHECK(!owner->result_ok);
5076         return PaymentSendFailure_clone(&*owner->contents.err);
5077 }
5078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5079         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
5080         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5081         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
5082         int64_t ret_ref = (uintptr_t)ret_copy;
5083         return ret_ref;
5084 }
5085
5086 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5087 CHECK(owner->result_ok);
5088         return *owner->contents.result;
5089 }
5090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5091         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5092         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
5093 }
5094
5095 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5096 CHECK(!owner->result_ok);
5097         return PaymentSendFailure_clone(&*owner->contents.err);
5098 }
5099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5100         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
5101         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5102         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
5103         int64_t ret_ref = (uintptr_t)ret_copy;
5104         return ret_ref;
5105 }
5106
5107 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5108         return ThirtyTwoBytes_clone(&owner->a);
5109 }
5110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5111         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5112         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5113         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
5114         return ret_arr;
5115 }
5116
5117 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
5118         return ThirtyTwoBytes_clone(&owner->b);
5119 }
5120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5121         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
5122         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5123         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
5124         return ret_arr;
5125 }
5126
5127 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5128 CHECK(owner->result_ok);
5129         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
5130 }
5131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5132         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5133         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
5134         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
5135         return ((int64_t)ret_conv);
5136 }
5137
5138 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
5139 CHECK(!owner->result_ok);
5140         return PaymentSendFailure_clone(&*owner->contents.err);
5141 }
5142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5143         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
5144         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5145         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
5146         int64_t ret_ref = (uintptr_t)ret_copy;
5147         return ret_ref;
5148 }
5149
5150 static jclass LDKNetAddress_IPv4_class = NULL;
5151 static jmethodID LDKNetAddress_IPv4_meth = NULL;
5152 static jclass LDKNetAddress_IPv6_class = NULL;
5153 static jmethodID LDKNetAddress_IPv6_meth = NULL;
5154 static jclass LDKNetAddress_OnionV2_class = NULL;
5155 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
5156 static jclass LDKNetAddress_OnionV3_class = NULL;
5157 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
5158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
5159         LDKNetAddress_IPv4_class =
5160                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
5161         CHECK(LDKNetAddress_IPv4_class != NULL);
5162         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
5163         CHECK(LDKNetAddress_IPv4_meth != NULL);
5164         LDKNetAddress_IPv6_class =
5165                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
5166         CHECK(LDKNetAddress_IPv6_class != NULL);
5167         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
5168         CHECK(LDKNetAddress_IPv6_meth != NULL);
5169         LDKNetAddress_OnionV2_class =
5170                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
5171         CHECK(LDKNetAddress_OnionV2_class != NULL);
5172         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
5173         CHECK(LDKNetAddress_OnionV2_meth != NULL);
5174         LDKNetAddress_OnionV3_class =
5175                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
5176         CHECK(LDKNetAddress_OnionV3_class != NULL);
5177         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
5178         CHECK(LDKNetAddress_OnionV3_meth != NULL);
5179 }
5180 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5181         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
5182         switch(obj->tag) {
5183                 case LDKNetAddress_IPv4: {
5184                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
5185                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
5186                         int16_t port_conv = obj->i_pv4.port;
5187                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
5188                 }
5189                 case LDKNetAddress_IPv6: {
5190                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
5191                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
5192                         int16_t port_conv = obj->i_pv6.port;
5193                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
5194                 }
5195                 case LDKNetAddress_OnionV2: {
5196                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
5197                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
5198                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
5199                 }
5200                 case LDKNetAddress_OnionV3: {
5201                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
5202                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
5203                         int16_t checksum_conv = obj->onion_v3.checksum;
5204                         int8_t version_conv = obj->onion_v3.version;
5205                         int16_t port_conv = obj->onion_v3.port;
5206                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
5207                 }
5208                 default: abort();
5209         }
5210 }
5211 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
5212         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
5213         for (size_t i = 0; i < ret.datalen; i++) {
5214                 ret.data[i] = NetAddress_clone(&orig->data[i]);
5215         }
5216         return ret;
5217 }
5218 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5219         return ThirtyTwoBytes_clone(&owner->a);
5220 }
5221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5222         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5223         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5224         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
5225         return ret_arr;
5226 }
5227
5228 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
5229         return ThirtyTwoBytes_clone(&owner->b);
5230 }
5231 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5232         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
5233         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5234         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
5235         return ret_arr;
5236 }
5237
5238 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5239 CHECK(owner->result_ok);
5240         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5241 }
5242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5243         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5244         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5245         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
5246         return ((int64_t)ret_conv);
5247 }
5248
5249 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
5250 CHECK(!owner->result_ok);
5251         return *owner->contents.err;
5252 }
5253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5254         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
5255         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
5256 }
5257
5258 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5259 CHECK(owner->result_ok);
5260         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
5261 }
5262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5263         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5264         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
5265         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
5266         return ((int64_t)ret_conv);
5267 }
5268
5269 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
5270 CHECK(!owner->result_ok);
5271         return APIError_clone(&*owner->contents.err);
5272 }
5273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5274         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
5275         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5276         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
5277         int64_t ret_ref = (uintptr_t)ret_copy;
5278         return ret_ref;
5279 }
5280
5281 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5282 CHECK(owner->result_ok);
5283         return ThirtyTwoBytes_clone(&*owner->contents.result);
5284 }
5285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5286         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5287         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5288         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
5289         return ret_arr;
5290 }
5291
5292 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
5293 CHECK(!owner->result_ok);
5294         return *owner->contents.err;
5295 }
5296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5297         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
5298         CResult_PaymentSecretNoneZ_get_err(owner_conv);
5299 }
5300
5301 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5302 CHECK(owner->result_ok);
5303         return ThirtyTwoBytes_clone(&*owner->contents.result);
5304 }
5305 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5306         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5307         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5308         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
5309         return ret_arr;
5310 }
5311
5312 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
5313 CHECK(!owner->result_ok);
5314         return APIError_clone(&*owner->contents.err);
5315 }
5316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5317         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
5318         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5319         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
5320         int64_t ret_ref = (uintptr_t)ret_copy;
5321         return ret_ref;
5322 }
5323
5324 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5325 CHECK(owner->result_ok);
5326         return ThirtyTwoBytes_clone(&*owner->contents.result);
5327 }
5328 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5329         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5330         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5331         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
5332         return ret_arr;
5333 }
5334
5335 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
5336 CHECK(!owner->result_ok);
5337         return APIError_clone(&*owner->contents.err);
5338 }
5339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5340         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
5341         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5342         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
5343         int64_t ret_ref = (uintptr_t)ret_copy;
5344         return ret_ref;
5345 }
5346
5347 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5348 CHECK(owner->result_ok);
5349         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
5350 }
5351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5352         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5353         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
5354         int64_t ret_ref = 0;
5355         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5356         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5358         ret_ref = (uintptr_t)ret_var.inner;
5359         if (ret_var.is_owned) {
5360                 ret_ref |= 1;
5361         }
5362         return ret_ref;
5363 }
5364
5365 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5366 CHECK(!owner->result_ok);
5367         return DecodeError_clone(&*owner->contents.err);
5368 }
5369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5370         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
5371         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
5372         int64_t ret_ref = 0;
5373         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5374         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5376         ret_ref = (uintptr_t)ret_var.inner;
5377         if (ret_var.is_owned) {
5378                 ret_ref |= 1;
5379         }
5380         return ret_ref;
5381 }
5382
5383 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5384 CHECK(owner->result_ok);
5385         return ChannelCounterparty_clone(&*owner->contents.result);
5386 }
5387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5388         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5389         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
5390         int64_t ret_ref = 0;
5391         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5392         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5394         ret_ref = (uintptr_t)ret_var.inner;
5395         if (ret_var.is_owned) {
5396                 ret_ref |= 1;
5397         }
5398         return ret_ref;
5399 }
5400
5401 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5402 CHECK(!owner->result_ok);
5403         return DecodeError_clone(&*owner->contents.err);
5404 }
5405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5406         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
5407         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
5408         int64_t ret_ref = 0;
5409         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5410         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5412         ret_ref = (uintptr_t)ret_var.inner;
5413         if (ret_var.is_owned) {
5414                 ret_ref |= 1;
5415         }
5416         return ret_ref;
5417 }
5418
5419 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5420 CHECK(owner->result_ok);
5421         return ChannelDetails_clone(&*owner->contents.result);
5422 }
5423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5424         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5425         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5426         int64_t ret_ref = 0;
5427         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5428         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5430         ret_ref = (uintptr_t)ret_var.inner;
5431         if (ret_var.is_owned) {
5432                 ret_ref |= 1;
5433         }
5434         return ret_ref;
5435 }
5436
5437 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5438 CHECK(!owner->result_ok);
5439         return DecodeError_clone(&*owner->contents.err);
5440 }
5441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5442         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
5443         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5444         int64_t ret_ref = 0;
5445         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5446         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5448         ret_ref = (uintptr_t)ret_var.inner;
5449         if (ret_var.is_owned) {
5450                 ret_ref |= 1;
5451         }
5452         return ret_ref;
5453 }
5454
5455 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5456 CHECK(owner->result_ok);
5457         return PhantomRouteHints_clone(&*owner->contents.result);
5458 }
5459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5460         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5461         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5462         int64_t ret_ref = 0;
5463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5466         ret_ref = (uintptr_t)ret_var.inner;
5467         if (ret_var.is_owned) {
5468                 ret_ref |= 1;
5469         }
5470         return ret_ref;
5471 }
5472
5473 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5474 CHECK(!owner->result_ok);
5475         return DecodeError_clone(&*owner->contents.err);
5476 }
5477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5478         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
5479         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5480         int64_t ret_ref = 0;
5481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5484         ret_ref = (uintptr_t)ret_var.inner;
5485         if (ret_var.is_owned) {
5486                 ret_ref |= 1;
5487         }
5488         return ret_ref;
5489 }
5490
5491 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5492         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5493         for (size_t i = 0; i < ret.datalen; i++) {
5494                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5495         }
5496         return ret;
5497 }
5498 typedef struct LDKWatch_JCalls {
5499         atomic_size_t refcnt;
5500         JavaVM *vm;
5501         jweak o;
5502         jmethodID watch_channel_meth;
5503         jmethodID update_channel_meth;
5504         jmethodID release_pending_monitor_events_meth;
5505 } LDKWatch_JCalls;
5506 static void LDKWatch_JCalls_free(void* this_arg) {
5507         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5508         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5509                 JNIEnv *env;
5510                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5511                 if (get_jenv_res == JNI_EDETACHED) {
5512                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5513                 } else {
5514                         DO_ASSERT(get_jenv_res == JNI_OK);
5515                 }
5516                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5517                 if (get_jenv_res == JNI_EDETACHED) {
5518                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5519                 }
5520                 FREE(j_calls);
5521         }
5522 }
5523 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5524         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5525         JNIEnv *env;
5526         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5527         if (get_jenv_res == JNI_EDETACHED) {
5528                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5529         } else {
5530                 DO_ASSERT(get_jenv_res == JNI_OK);
5531         }
5532         LDKOutPoint funding_txo_var = funding_txo;
5533         int64_t funding_txo_ref = 0;
5534         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5535         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5536         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5537         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5538         if (funding_txo_var.is_owned) {
5539                 funding_txo_ref |= 1;
5540         }
5541         LDKChannelMonitor monitor_var = monitor;
5542         int64_t monitor_ref = 0;
5543         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5544         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5545         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5546         monitor_ref = (uintptr_t)monitor_var.inner;
5547         if (monitor_var.is_owned) {
5548                 monitor_ref |= 1;
5549         }
5550         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5551         CHECK(obj != NULL);
5552         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
5553         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5554                 (*env)->ExceptionDescribe(env);
5555                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
5556         }
5557         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5558         CHECK_ACCESS(ret_ptr);
5559         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5560         FREE((void*)ret);
5561         if (get_jenv_res == JNI_EDETACHED) {
5562                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5563         }
5564         return ret_conv;
5565 }
5566 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5567         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5568         JNIEnv *env;
5569         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5570         if (get_jenv_res == JNI_EDETACHED) {
5571                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5572         } else {
5573                 DO_ASSERT(get_jenv_res == JNI_OK);
5574         }
5575         LDKOutPoint funding_txo_var = funding_txo;
5576         int64_t funding_txo_ref = 0;
5577         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5578         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5579         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5580         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5581         if (funding_txo_var.is_owned) {
5582                 funding_txo_ref |= 1;
5583         }
5584         LDKChannelMonitorUpdate update_var = update;
5585         int64_t update_ref = 0;
5586         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5587         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5588         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5589         update_ref = (uintptr_t)update_var.inner;
5590         if (update_var.is_owned) {
5591                 update_ref |= 1;
5592         }
5593         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5594         CHECK(obj != NULL);
5595         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
5596         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5597                 (*env)->ExceptionDescribe(env);
5598                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
5599         }
5600         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5601         CHECK_ACCESS(ret_ptr);
5602         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5603         FREE((void*)ret);
5604         if (get_jenv_res == JNI_EDETACHED) {
5605                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5606         }
5607         return ret_conv;
5608 }
5609 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5610         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5611         JNIEnv *env;
5612         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5613         if (get_jenv_res == JNI_EDETACHED) {
5614                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5615         } else {
5616                 DO_ASSERT(get_jenv_res == JNI_OK);
5617         }
5618         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5619         CHECK(obj != NULL);
5620         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
5621         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5622                 (*env)->ExceptionDescribe(env);
5623                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
5624         }
5625         LDKCVec_MonitorEventZ ret_constr;
5626         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
5627         if (ret_constr.datalen > 0)
5628                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
5629         else
5630                 ret_constr.data = NULL;
5631         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
5632         for (size_t o = 0; o < ret_constr.datalen; o++) {
5633                 int64_t ret_conv_14 = ret_vals[o];
5634                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
5635                 CHECK_ACCESS(ret_conv_14_ptr);
5636                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
5637                 FREE((void*)ret_conv_14);
5638                 ret_constr.data[o] = ret_conv_14_conv;
5639         }
5640         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
5641         if (get_jenv_res == JNI_EDETACHED) {
5642                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5643         }
5644         return ret_constr;
5645 }
5646 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5647         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5648         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5649 }
5650 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
5651         jclass c = (*env)->GetObjectClass(env, o);
5652         CHECK(c != NULL);
5653         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5654         atomic_init(&calls->refcnt, 1);
5655         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5656         calls->o = (*env)->NewWeakGlobalRef(env, o);
5657         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
5658         CHECK(calls->watch_channel_meth != NULL);
5659         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
5660         CHECK(calls->update_channel_meth != NULL);
5661         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
5662         CHECK(calls->release_pending_monitor_events_meth != NULL);
5663
5664         LDKWatch ret = {
5665                 .this_arg = (void*) calls,
5666                 .watch_channel = watch_channel_LDKWatch_jcall,
5667                 .update_channel = update_channel_LDKWatch_jcall,
5668                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5669                 .free = LDKWatch_JCalls_free,
5670         };
5671         return ret;
5672 }
5673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
5674         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5675         *res_ptr = LDKWatch_init(env, clz, o);
5676         return (uint64_t)res_ptr;
5677 }
5678 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) {
5679         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5680         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5681         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5682         LDKOutPoint funding_txo_conv;
5683         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5684         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5685         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5686         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5687         LDKChannelMonitor monitor_conv;
5688         monitor_conv.inner = (void*)(monitor & (~1));
5689         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5690         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5691         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5692         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5693         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5694         return (int64_t)ret_conv;
5695 }
5696
5697 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) {
5698         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5699         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5700         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5701         LDKOutPoint funding_txo_conv;
5702         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5703         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5704         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5705         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5706         LDKChannelMonitorUpdate update_conv;
5707         update_conv.inner = (void*)(update & (~1));
5708         update_conv.is_owned = (update & 1) || (update == 0);
5709         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5710         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5711         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5712         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5713         return (int64_t)ret_conv;
5714 }
5715
5716 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
5717         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5718         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5719         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5720         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5721         int64_tArray ret_arr = NULL;
5722         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5723         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5724         for (size_t o = 0; o < ret_var.datalen; o++) {
5725                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
5726                 *ret_conv_14_copy = ret_var.data[o];
5727                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
5728                 ret_arr_ptr[o] = ret_conv_14_ref;
5729         }
5730         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5731         FREE(ret_var.data);
5732         return ret_arr;
5733 }
5734
5735 typedef struct LDKBroadcasterInterface_JCalls {
5736         atomic_size_t refcnt;
5737         JavaVM *vm;
5738         jweak o;
5739         jmethodID broadcast_transaction_meth;
5740 } LDKBroadcasterInterface_JCalls;
5741 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5742         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5743         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5744                 JNIEnv *env;
5745                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5746                 if (get_jenv_res == JNI_EDETACHED) {
5747                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5748                 } else {
5749                         DO_ASSERT(get_jenv_res == JNI_OK);
5750                 }
5751                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5752                 if (get_jenv_res == JNI_EDETACHED) {
5753                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5754                 }
5755                 FREE(j_calls);
5756         }
5757 }
5758 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5759         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5760         JNIEnv *env;
5761         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5762         if (get_jenv_res == JNI_EDETACHED) {
5763                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5764         } else {
5765                 DO_ASSERT(get_jenv_res == JNI_OK);
5766         }
5767         LDKTransaction tx_var = tx;
5768         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
5769         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
5770         Transaction_free(tx_var);
5771         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5772         CHECK(obj != NULL);
5773         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
5774         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5775                 (*env)->ExceptionDescribe(env);
5776                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
5777         }
5778         if (get_jenv_res == JNI_EDETACHED) {
5779                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5780         }
5781 }
5782 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5783         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5784         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5785 }
5786 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
5787         jclass c = (*env)->GetObjectClass(env, o);
5788         CHECK(c != NULL);
5789         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5790         atomic_init(&calls->refcnt, 1);
5791         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5792         calls->o = (*env)->NewWeakGlobalRef(env, o);
5793         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
5794         CHECK(calls->broadcast_transaction_meth != NULL);
5795
5796         LDKBroadcasterInterface ret = {
5797                 .this_arg = (void*) calls,
5798                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5799                 .free = LDKBroadcasterInterface_JCalls_free,
5800         };
5801         return ret;
5802 }
5803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
5804         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5805         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
5806         return (uint64_t)res_ptr;
5807 }
5808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
5809         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5810         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5811         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5812         LDKTransaction tx_ref;
5813         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
5814         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5815         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
5816         tx_ref.data_is_owned = true;
5817         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5818 }
5819
5820 typedef struct LDKKeysInterface_JCalls {
5821         atomic_size_t refcnt;
5822         JavaVM *vm;
5823         jweak o;
5824         jmethodID get_node_secret_meth;
5825         jmethodID get_destination_script_meth;
5826         jmethodID get_shutdown_scriptpubkey_meth;
5827         jmethodID get_channel_signer_meth;
5828         jmethodID get_secure_random_bytes_meth;
5829         jmethodID read_chan_signer_meth;
5830         jmethodID sign_invoice_meth;
5831         jmethodID get_inbound_payment_key_material_meth;
5832 } LDKKeysInterface_JCalls;
5833 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5834         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5835         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5836                 JNIEnv *env;
5837                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5838                 if (get_jenv_res == JNI_EDETACHED) {
5839                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5840                 } else {
5841                         DO_ASSERT(get_jenv_res == JNI_OK);
5842                 }
5843                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5844                 if (get_jenv_res == JNI_EDETACHED) {
5845                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5846                 }
5847                 FREE(j_calls);
5848         }
5849 }
5850 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5851         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5852         JNIEnv *env;
5853         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5854         if (get_jenv_res == JNI_EDETACHED) {
5855                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5856         } else {
5857                 DO_ASSERT(get_jenv_res == JNI_OK);
5858         }
5859         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
5860         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5861         CHECK(obj != NULL);
5862         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
5863         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5864                 (*env)->ExceptionDescribe(env);
5865                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
5866         }
5867         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5868         CHECK_ACCESS(ret_ptr);
5869         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5870         FREE((void*)ret);
5871         if (get_jenv_res == JNI_EDETACHED) {
5872                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5873         }
5874         return ret_conv;
5875 }
5876 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5877         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5878         JNIEnv *env;
5879         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5880         if (get_jenv_res == JNI_EDETACHED) {
5881                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5882         } else {
5883                 DO_ASSERT(get_jenv_res == JNI_OK);
5884         }
5885         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5886         CHECK(obj != NULL);
5887         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
5888         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5889                 (*env)->ExceptionDescribe(env);
5890                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
5891         }
5892         LDKCVec_u8Z ret_ref;
5893         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5894         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5895         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5896         if (get_jenv_res == JNI_EDETACHED) {
5897                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5898         }
5899         return ret_ref;
5900 }
5901 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5902         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5903         JNIEnv *env;
5904         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5905         if (get_jenv_res == JNI_EDETACHED) {
5906                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5907         } else {
5908                 DO_ASSERT(get_jenv_res == JNI_OK);
5909         }
5910         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5911         CHECK(obj != NULL);
5912         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
5913         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5914                 (*env)->ExceptionDescribe(env);
5915                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
5916         }
5917         LDKShutdownScript ret_conv;
5918         ret_conv.inner = (void*)(ret & (~1));
5919         ret_conv.is_owned = (ret & 1) || (ret == 0);
5920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5921         if (get_jenv_res == JNI_EDETACHED) {
5922                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5923         }
5924         return ret_conv;
5925 }
5926 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5927         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5928         JNIEnv *env;
5929         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5930         if (get_jenv_res == JNI_EDETACHED) {
5931                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5932         } else {
5933                 DO_ASSERT(get_jenv_res == JNI_OK);
5934         }
5935         jboolean inbound_conv = inbound;
5936         int64_t channel_value_satoshis_conv = channel_value_satoshis;
5937         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5938         CHECK(obj != NULL);
5939         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
5940         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5941                 (*env)->ExceptionDescribe(env);
5942                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
5943         }
5944         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5945         CHECK_ACCESS(ret_ptr);
5946         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5947         FREE((void*)ret);
5948         if (get_jenv_res == JNI_EDETACHED) {
5949                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5950         }
5951         return ret_conv;
5952 }
5953 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5954         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5955         JNIEnv *env;
5956         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5957         if (get_jenv_res == JNI_EDETACHED) {
5958                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5959         } else {
5960                 DO_ASSERT(get_jenv_res == JNI_OK);
5961         }
5962         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5963         CHECK(obj != NULL);
5964         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
5965         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5966                 (*env)->ExceptionDescribe(env);
5967                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
5968         }
5969         LDKThirtyTwoBytes ret_ref;
5970         CHECK((*env)->GetArrayLength(env, ret) == 32);
5971         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5972         if (get_jenv_res == JNI_EDETACHED) {
5973                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5974         }
5975         return ret_ref;
5976 }
5977 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5978         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5979         JNIEnv *env;
5980         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5981         if (get_jenv_res == JNI_EDETACHED) {
5982                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5983         } else {
5984                 DO_ASSERT(get_jenv_res == JNI_OK);
5985         }
5986         LDKu8slice reader_var = reader;
5987         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
5988         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
5989         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5990         CHECK(obj != NULL);
5991         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
5992         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5993                 (*env)->ExceptionDescribe(env);
5994                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
5995         }
5996         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5997         CHECK_ACCESS(ret_ptr);
5998         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5999         FREE((void*)ret);
6000         if (get_jenv_res == JNI_EDETACHED) {
6001                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6002         }
6003         return ret_conv;
6004 }
6005 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
6006         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6007         JNIEnv *env;
6008         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6009         if (get_jenv_res == JNI_EDETACHED) {
6010                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6011         } else {
6012                 DO_ASSERT(get_jenv_res == JNI_OK);
6013         }
6014         LDKu8slice hrp_bytes_var = hrp_bytes;
6015         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
6016         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
6017         LDKCVec_u5Z invoice_data_var = invoice_data;
6018         jobjectArray invoice_data_arr = NULL;
6019         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
6020         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
6021         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
6022                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
6023                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
6024         }
6025         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
6026         FREE(invoice_data_var.data);
6027         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
6028         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6029         CHECK(obj != NULL);
6030         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
6031         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6032                 (*env)->ExceptionDescribe(env);
6033                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
6034         }
6035         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6036         CHECK_ACCESS(ret_ptr);
6037         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6038         FREE((void*)ret);
6039         if (get_jenv_res == JNI_EDETACHED) {
6040                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6041         }
6042         return ret_conv;
6043 }
6044 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
6045         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6046         JNIEnv *env;
6047         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6048         if (get_jenv_res == JNI_EDETACHED) {
6049                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6050         } else {
6051                 DO_ASSERT(get_jenv_res == JNI_OK);
6052         }
6053         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6054         CHECK(obj != NULL);
6055         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
6056         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6057                 (*env)->ExceptionDescribe(env);
6058                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
6059         }
6060         LDKThirtyTwoBytes ret_ref;
6061         CHECK((*env)->GetArrayLength(env, ret) == 32);
6062         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
6063         if (get_jenv_res == JNI_EDETACHED) {
6064                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6065         }
6066         return ret_ref;
6067 }
6068 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
6069         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
6070         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6071 }
6072 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
6073         jclass c = (*env)->GetObjectClass(env, o);
6074         CHECK(c != NULL);
6075         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
6076         atomic_init(&calls->refcnt, 1);
6077         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6078         calls->o = (*env)->NewWeakGlobalRef(env, o);
6079         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
6080         CHECK(calls->get_node_secret_meth != NULL);
6081         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
6082         CHECK(calls->get_destination_script_meth != NULL);
6083         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
6084         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
6085         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
6086         CHECK(calls->get_channel_signer_meth != NULL);
6087         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
6088         CHECK(calls->get_secure_random_bytes_meth != NULL);
6089         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
6090         CHECK(calls->read_chan_signer_meth != NULL);
6091         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
6092         CHECK(calls->sign_invoice_meth != NULL);
6093         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
6094         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
6095
6096         LDKKeysInterface ret = {
6097                 .this_arg = (void*) calls,
6098                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
6099                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
6100                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
6101                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
6102                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
6103                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
6104                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
6105                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
6106                 .free = LDKKeysInterface_JCalls_free,
6107         };
6108         return ret;
6109 }
6110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
6111         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6112         *res_ptr = LDKKeysInterface_init(env, clz, o);
6113         return (uint64_t)res_ptr;
6114 }
6115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
6116         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6117         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6118         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6119         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
6120         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
6121         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
6122         return (int64_t)ret_conv;
6123 }
6124
6125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
6126         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6127         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6128         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6129         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6130         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6131         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6132         CVec_u8Z_free(ret_var);
6133         return ret_arr;
6134 }
6135
6136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
6137         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6138         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6139         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6140         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6141         int64_t ret_ref = 0;
6142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6145         ret_ref = (uintptr_t)ret_var.inner;
6146         if (ret_var.is_owned) {
6147                 ret_ref |= 1;
6148         }
6149         return ret_ref;
6150 }
6151
6152 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) {
6153         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6154         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6155         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6156         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6157         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6158         return (int64_t)ret_ret;
6159 }
6160
6161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
6162         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6163         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6164         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6165         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6166         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
6167         return ret_arr;
6168 }
6169
6170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
6171         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6172         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6173         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6174         LDKu8slice reader_ref;
6175         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
6176         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
6177         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6178         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6179         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
6180         return (int64_t)ret_conv;
6181 }
6182
6183 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) {
6184         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6185         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6186         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6187         LDKu8slice hrp_bytes_ref;
6188         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
6189         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
6190         LDKCVec_u5Z invoice_data_constr;
6191         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
6192         if (invoice_data_constr.datalen > 0)
6193                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
6194         else
6195                 invoice_data_constr.data = NULL;
6196         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
6197         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
6198                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
6199                 
6200                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
6201         }
6202         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
6203         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
6204         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6205         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
6206         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
6207         return (int64_t)ret_conv;
6208 }
6209
6210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
6211         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6212         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6213         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6214         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6215         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
6216         return ret_arr;
6217 }
6218
6219 typedef struct LDKFeeEstimator_JCalls {
6220         atomic_size_t refcnt;
6221         JavaVM *vm;
6222         jweak o;
6223         jmethodID get_est_sat_per_1000_weight_meth;
6224 } LDKFeeEstimator_JCalls;
6225 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6226         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6227         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6228                 JNIEnv *env;
6229                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6230                 if (get_jenv_res == JNI_EDETACHED) {
6231                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6232                 } else {
6233                         DO_ASSERT(get_jenv_res == JNI_OK);
6234                 }
6235                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6236                 if (get_jenv_res == JNI_EDETACHED) {
6237                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6238                 }
6239                 FREE(j_calls);
6240         }
6241 }
6242 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6243         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6244         JNIEnv *env;
6245         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6246         if (get_jenv_res == JNI_EDETACHED) {
6247                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6248         } else {
6249                 DO_ASSERT(get_jenv_res == JNI_OK);
6250         }
6251         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
6252         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6253         CHECK(obj != NULL);
6254         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
6255         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6256                 (*env)->ExceptionDescribe(env);
6257                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
6258         }
6259         if (get_jenv_res == JNI_EDETACHED) {
6260                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6261         }
6262         return ret;
6263 }
6264 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6265         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6266         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6267 }
6268 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
6269         jclass c = (*env)->GetObjectClass(env, o);
6270         CHECK(c != NULL);
6271         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6272         atomic_init(&calls->refcnt, 1);
6273         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6274         calls->o = (*env)->NewWeakGlobalRef(env, o);
6275         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
6276         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
6277
6278         LDKFeeEstimator ret = {
6279                 .this_arg = (void*) calls,
6280                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6281                 .free = LDKFeeEstimator_JCalls_free,
6282         };
6283         return ret;
6284 }
6285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
6286         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6287         *res_ptr = LDKFeeEstimator_init(env, clz, o);
6288         return (uint64_t)res_ptr;
6289 }
6290 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) {
6291         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6292         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6293         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6294         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
6295         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6296         return ret_conv;
6297 }
6298
6299 typedef struct LDKLogger_JCalls {
6300         atomic_size_t refcnt;
6301         JavaVM *vm;
6302         jweak o;
6303         jmethodID log_meth;
6304 } LDKLogger_JCalls;
6305 static void LDKLogger_JCalls_free(void* this_arg) {
6306         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6307         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6308                 JNIEnv *env;
6309                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6310                 if (get_jenv_res == JNI_EDETACHED) {
6311                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6312                 } else {
6313                         DO_ASSERT(get_jenv_res == JNI_OK);
6314                 }
6315                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6316                 if (get_jenv_res == JNI_EDETACHED) {
6317                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6318                 }
6319                 FREE(j_calls);
6320         }
6321 }
6322 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
6323         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6324         JNIEnv *env;
6325         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6326         if (get_jenv_res == JNI_EDETACHED) {
6327                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6328         } else {
6329                 DO_ASSERT(get_jenv_res == JNI_OK);
6330         }
6331         LDKRecord record_var = *record;
6332         int64_t record_ref = 0;
6333         record_var = Record_clone(&record_var);
6334         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6335         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6336         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
6337         record_ref = (uintptr_t)record_var.inner;
6338         if (record_var.is_owned) {
6339                 record_ref |= 1;
6340         }
6341         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6342         CHECK(obj != NULL);
6343         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
6344         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6345                 (*env)->ExceptionDescribe(env);
6346                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
6347         }
6348         if (get_jenv_res == JNI_EDETACHED) {
6349                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6350         }
6351 }
6352 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
6353         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
6354         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6355 }
6356 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
6357         jclass c = (*env)->GetObjectClass(env, o);
6358         CHECK(c != NULL);
6359         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
6360         atomic_init(&calls->refcnt, 1);
6361         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6362         calls->o = (*env)->NewWeakGlobalRef(env, o);
6363         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
6364         CHECK(calls->log_meth != NULL);
6365
6366         LDKLogger ret = {
6367                 .this_arg = (void*) calls,
6368                 .log = log_LDKLogger_jcall,
6369                 .free = LDKLogger_JCalls_free,
6370         };
6371         return ret;
6372 }
6373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
6374         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
6375         *res_ptr = LDKLogger_init(env, clz, o);
6376         return (uint64_t)res_ptr;
6377 }
6378 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6379         return ThirtyTwoBytes_clone(&owner->a);
6380 }
6381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6382         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6383         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6384         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
6385         return ret_arr;
6386 }
6387
6388 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6389         return &owner->b;
6390 }
6391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6392         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6393         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
6394         int64_t ret_ref = 0;
6395         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6396         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6398         ret_ref = (uintptr_t)ret_var.inner & ~1;
6399         return ret_ref;
6400 }
6401
6402 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6403 CHECK(owner->result_ok);
6404         return &*owner->contents.result;
6405 }
6406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6407         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6408         int64_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
6409         return ret_ret;
6410 }
6411
6412 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6413 CHECK(!owner->result_ok);
6414         return DecodeError_clone(&*owner->contents.err);
6415 }
6416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6417         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6418         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
6419         int64_t ret_ref = 0;
6420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6423         ret_ref = (uintptr_t)ret_var.inner;
6424         if (ret_var.is_owned) {
6425                 ret_ref |= 1;
6426         }
6427         return ret_ref;
6428 }
6429
6430 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6431 CHECK(owner->result_ok);
6432         return ChannelConfig_clone(&*owner->contents.result);
6433 }
6434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6435         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
6436         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
6437         int64_t ret_ref = 0;
6438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6441         ret_ref = (uintptr_t)ret_var.inner;
6442         if (ret_var.is_owned) {
6443                 ret_ref |= 1;
6444         }
6445         return ret_ref;
6446 }
6447
6448 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6449 CHECK(!owner->result_ok);
6450         return DecodeError_clone(&*owner->contents.err);
6451 }
6452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6453         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
6454         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
6455         int64_t ret_ref = 0;
6456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6459         ret_ref = (uintptr_t)ret_var.inner;
6460         if (ret_var.is_owned) {
6461                 ret_ref |= 1;
6462         }
6463         return ret_ref;
6464 }
6465
6466 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6467 CHECK(owner->result_ok);
6468         return OutPoint_clone(&*owner->contents.result);
6469 }
6470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6471         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
6472         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
6473         int64_t ret_ref = 0;
6474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6477         ret_ref = (uintptr_t)ret_var.inner;
6478         if (ret_var.is_owned) {
6479                 ret_ref |= 1;
6480         }
6481         return ret_ref;
6482 }
6483
6484 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
6485 CHECK(!owner->result_ok);
6486         return DecodeError_clone(&*owner->contents.err);
6487 }
6488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6489         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
6490         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
6491         int64_t ret_ref = 0;
6492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6495         ret_ref = (uintptr_t)ret_var.inner;
6496         if (ret_var.is_owned) {
6497                 ret_ref |= 1;
6498         }
6499         return ret_ref;
6500 }
6501
6502 typedef struct LDKType_JCalls {
6503         atomic_size_t refcnt;
6504         JavaVM *vm;
6505         jweak o;
6506         jmethodID type_id_meth;
6507         jmethodID debug_str_meth;
6508         jmethodID write_meth;
6509 } LDKType_JCalls;
6510 static void LDKType_JCalls_free(void* this_arg) {
6511         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6512         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6513                 JNIEnv *env;
6514                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6515                 if (get_jenv_res == JNI_EDETACHED) {
6516                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6517                 } else {
6518                         DO_ASSERT(get_jenv_res == JNI_OK);
6519                 }
6520                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6521                 if (get_jenv_res == JNI_EDETACHED) {
6522                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6523                 }
6524                 FREE(j_calls);
6525         }
6526 }
6527 uint16_t type_id_LDKType_jcall(const void* this_arg) {
6528         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6529         JNIEnv *env;
6530         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6531         if (get_jenv_res == JNI_EDETACHED) {
6532                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6533         } else {
6534                 DO_ASSERT(get_jenv_res == JNI_OK);
6535         }
6536         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6537         CHECK(obj != NULL);
6538         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
6539         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6540                 (*env)->ExceptionDescribe(env);
6541                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
6542         }
6543         if (get_jenv_res == JNI_EDETACHED) {
6544                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6545         }
6546         return ret;
6547 }
6548 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
6549         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6550         JNIEnv *env;
6551         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6552         if (get_jenv_res == JNI_EDETACHED) {
6553                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6554         } else {
6555                 DO_ASSERT(get_jenv_res == JNI_OK);
6556         }
6557         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6558         CHECK(obj != NULL);
6559         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
6560         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6561                 (*env)->ExceptionDescribe(env);
6562                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
6563         }
6564         LDKStr ret_conv = java_to_owned_str(env, ret);
6565         if (get_jenv_res == JNI_EDETACHED) {
6566                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6567         }
6568         return ret_conv;
6569 }
6570 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
6571         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
6572         JNIEnv *env;
6573         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6574         if (get_jenv_res == JNI_EDETACHED) {
6575                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6576         } else {
6577                 DO_ASSERT(get_jenv_res == JNI_OK);
6578         }
6579         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6580         CHECK(obj != NULL);
6581         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
6582         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6583                 (*env)->ExceptionDescribe(env);
6584                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
6585         }
6586         LDKCVec_u8Z ret_ref;
6587         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6588         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6589         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6590         if (get_jenv_res == JNI_EDETACHED) {
6591                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6592         }
6593         return ret_ref;
6594 }
6595 static void LDKType_JCalls_cloned(LDKType* new_obj) {
6596         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
6597         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6598 }
6599 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
6600         jclass c = (*env)->GetObjectClass(env, o);
6601         CHECK(c != NULL);
6602         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
6603         atomic_init(&calls->refcnt, 1);
6604         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6605         calls->o = (*env)->NewWeakGlobalRef(env, o);
6606         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
6607         CHECK(calls->type_id_meth != NULL);
6608         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
6609         CHECK(calls->debug_str_meth != NULL);
6610         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6611         CHECK(calls->write_meth != NULL);
6612
6613         LDKType ret = {
6614                 .this_arg = (void*) calls,
6615                 .type_id = type_id_LDKType_jcall,
6616                 .debug_str = debug_str_LDKType_jcall,
6617                 .write = write_LDKType_jcall,
6618                 .cloned = LDKType_JCalls_cloned,
6619                 .free = LDKType_JCalls_free,
6620         };
6621         return ret;
6622 }
6623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
6624         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
6625         *res_ptr = LDKType_init(env, clz, o);
6626         return (uint64_t)res_ptr;
6627 }
6628 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
6629         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6630         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6631         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6632         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
6633         return ret_conv;
6634 }
6635
6636 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
6637         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6638         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6639         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6640         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
6641         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
6642         Str_free(ret_str);
6643         return ret_conv;
6644 }
6645
6646 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6647         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6648         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6649         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
6650         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6651         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6652         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6653         CVec_u8Z_free(ret_var);
6654         return ret_arr;
6655 }
6656
6657 static jclass LDKCOption_TypeZ_Some_class = NULL;
6658 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
6659 static jclass LDKCOption_TypeZ_None_class = NULL;
6660 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
6661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
6662         LDKCOption_TypeZ_Some_class =
6663                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
6664         CHECK(LDKCOption_TypeZ_Some_class != NULL);
6665         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
6666         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
6667         LDKCOption_TypeZ_None_class =
6668                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
6669         CHECK(LDKCOption_TypeZ_None_class != NULL);
6670         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
6671         CHECK(LDKCOption_TypeZ_None_meth != NULL);
6672 }
6673 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6674         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
6675         switch(obj->tag) {
6676                 case LDKCOption_TypeZ_Some: {
6677                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
6678                         *some_ret = Type_clone(&obj->some);
6679                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (int64_t)some_ret);
6680                 }
6681                 case LDKCOption_TypeZ_None: {
6682                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
6683                 }
6684                 default: abort();
6685         }
6686 }
6687 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6688 CHECK(owner->result_ok);
6689         return COption_TypeZ_clone(&*owner->contents.result);
6690 }
6691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6692         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6693         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
6694         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
6695         int64_t ret_ref = (uintptr_t)ret_copy;
6696         return ret_ref;
6697 }
6698
6699 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
6700 CHECK(!owner->result_ok);
6701         return DecodeError_clone(&*owner->contents.err);
6702 }
6703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6704         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
6705         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
6706         int64_t ret_ref = 0;
6707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6710         ret_ref = (uintptr_t)ret_var.inner;
6711         if (ret_var.is_owned) {
6712                 ret_ref |= 1;
6713         }
6714         return ret_ref;
6715 }
6716
6717 static jclass LDKPaymentError_Invoice_class = NULL;
6718 static jmethodID LDKPaymentError_Invoice_meth = NULL;
6719 static jclass LDKPaymentError_Routing_class = NULL;
6720 static jmethodID LDKPaymentError_Routing_meth = NULL;
6721 static jclass LDKPaymentError_Sending_class = NULL;
6722 static jmethodID LDKPaymentError_Sending_meth = NULL;
6723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
6724         LDKPaymentError_Invoice_class =
6725                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
6726         CHECK(LDKPaymentError_Invoice_class != NULL);
6727         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
6728         CHECK(LDKPaymentError_Invoice_meth != NULL);
6729         LDKPaymentError_Routing_class =
6730                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
6731         CHECK(LDKPaymentError_Routing_class != NULL);
6732         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
6733         CHECK(LDKPaymentError_Routing_meth != NULL);
6734         LDKPaymentError_Sending_class =
6735                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
6736         CHECK(LDKPaymentError_Sending_class != NULL);
6737         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
6738         CHECK(LDKPaymentError_Sending_meth != NULL);
6739 }
6740 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6741         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
6742         switch(obj->tag) {
6743                 case LDKPaymentError_Invoice: {
6744                         LDKStr invoice_str = obj->invoice;
6745                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
6746                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
6747                 }
6748                 case LDKPaymentError_Routing: {
6749                         LDKLightningError routing_var = obj->routing;
6750                         int64_t routing_ref = 0;
6751                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6752                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6753                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
6754                         routing_ref = (uintptr_t)routing_var.inner & ~1;
6755                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
6756                 }
6757                 case LDKPaymentError_Sending: {
6758                         int64_t sending_ref = ((uintptr_t)&obj->sending) | 1;
6759                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
6760                 }
6761                 default: abort();
6762         }
6763 }
6764 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6765 CHECK(owner->result_ok);
6766         return ThirtyTwoBytes_clone(&*owner->contents.result);
6767 }
6768 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6769         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6770         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6771         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
6772         return ret_arr;
6773 }
6774
6775 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
6776 CHECK(!owner->result_ok);
6777         return PaymentError_clone(&*owner->contents.err);
6778 }
6779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6780         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
6781         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
6782         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
6783         int64_t ret_ref = (uintptr_t)ret_copy;
6784         return ret_ref;
6785 }
6786
6787 static jclass LDKParseError_Bech32Error_class = NULL;
6788 static jmethodID LDKParseError_Bech32Error_meth = NULL;
6789 static jclass LDKParseError_ParseAmountError_class = NULL;
6790 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
6791 static jclass LDKParseError_MalformedSignature_class = NULL;
6792 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
6793 static jclass LDKParseError_BadPrefix_class = NULL;
6794 static jmethodID LDKParseError_BadPrefix_meth = NULL;
6795 static jclass LDKParseError_UnknownCurrency_class = NULL;
6796 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
6797 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
6798 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
6799 static jclass LDKParseError_MalformedHRP_class = NULL;
6800 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
6801 static jclass LDKParseError_TooShortDataPart_class = NULL;
6802 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
6803 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
6804 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
6805 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
6806 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
6807 static jclass LDKParseError_PaddingError_class = NULL;
6808 static jmethodID LDKParseError_PaddingError_meth = NULL;
6809 static jclass LDKParseError_IntegerOverflowError_class = NULL;
6810 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
6811 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
6812 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
6813 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
6814 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
6815 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
6816 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
6817 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
6818 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
6819 static jclass LDKParseError_InvalidSliceLength_class = NULL;
6820 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
6821 static jclass LDKParseError_Skip_class = NULL;
6822 static jmethodID LDKParseError_Skip_meth = NULL;
6823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
6824         LDKParseError_Bech32Error_class =
6825                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
6826         CHECK(LDKParseError_Bech32Error_class != NULL);
6827         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
6828         CHECK(LDKParseError_Bech32Error_meth != NULL);
6829         LDKParseError_ParseAmountError_class =
6830                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
6831         CHECK(LDKParseError_ParseAmountError_class != NULL);
6832         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
6833         CHECK(LDKParseError_ParseAmountError_meth != NULL);
6834         LDKParseError_MalformedSignature_class =
6835                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
6836         CHECK(LDKParseError_MalformedSignature_class != NULL);
6837         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
6838         CHECK(LDKParseError_MalformedSignature_meth != NULL);
6839         LDKParseError_BadPrefix_class =
6840                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
6841         CHECK(LDKParseError_BadPrefix_class != NULL);
6842         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
6843         CHECK(LDKParseError_BadPrefix_meth != NULL);
6844         LDKParseError_UnknownCurrency_class =
6845                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
6846         CHECK(LDKParseError_UnknownCurrency_class != NULL);
6847         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
6848         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
6849         LDKParseError_UnknownSiPrefix_class =
6850                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
6851         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
6852         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
6853         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
6854         LDKParseError_MalformedHRP_class =
6855                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
6856         CHECK(LDKParseError_MalformedHRP_class != NULL);
6857         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
6858         CHECK(LDKParseError_MalformedHRP_meth != NULL);
6859         LDKParseError_TooShortDataPart_class =
6860                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
6861         CHECK(LDKParseError_TooShortDataPart_class != NULL);
6862         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
6863         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
6864         LDKParseError_UnexpectedEndOfTaggedFields_class =
6865                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
6866         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
6867         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
6868         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
6869         LDKParseError_DescriptionDecodeError_class =
6870                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
6871         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
6872         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
6873         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
6874         LDKParseError_PaddingError_class =
6875                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
6876         CHECK(LDKParseError_PaddingError_class != NULL);
6877         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
6878         CHECK(LDKParseError_PaddingError_meth != NULL);
6879         LDKParseError_IntegerOverflowError_class =
6880                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
6881         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
6882         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
6883         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
6884         LDKParseError_InvalidSegWitProgramLength_class =
6885                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
6886         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
6887         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
6888         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
6889         LDKParseError_InvalidPubKeyHashLength_class =
6890                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
6891         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
6892         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
6893         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
6894         LDKParseError_InvalidScriptHashLength_class =
6895                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
6896         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
6897         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
6898         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
6899         LDKParseError_InvalidRecoveryId_class =
6900                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
6901         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
6902         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
6903         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
6904         LDKParseError_InvalidSliceLength_class =
6905                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
6906         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
6907         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
6908         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
6909         LDKParseError_Skip_class =
6910                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
6911         CHECK(LDKParseError_Skip_class != NULL);
6912         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
6913         CHECK(LDKParseError_Skip_meth != NULL);
6914 }
6915 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6916         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
6917         switch(obj->tag) {
6918                 case LDKParseError_Bech32Error: {
6919                         int64_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
6920                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
6921                 }
6922                 case LDKParseError_ParseAmountError: {
6923                         /*obj->parse_amount_error*/
6924                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
6925                 }
6926                 case LDKParseError_MalformedSignature: {
6927                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
6928                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
6929                 }
6930                 case LDKParseError_BadPrefix: {
6931                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
6932                 }
6933                 case LDKParseError_UnknownCurrency: {
6934                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
6935                 }
6936                 case LDKParseError_UnknownSiPrefix: {
6937                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
6938                 }
6939                 case LDKParseError_MalformedHRP: {
6940                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
6941                 }
6942                 case LDKParseError_TooShortDataPart: {
6943                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
6944                 }
6945                 case LDKParseError_UnexpectedEndOfTaggedFields: {
6946                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
6947                 }
6948                 case LDKParseError_DescriptionDecodeError: {
6949                         /*obj->description_decode_error*/
6950                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
6951                 }
6952                 case LDKParseError_PaddingError: {
6953                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
6954                 }
6955                 case LDKParseError_IntegerOverflowError: {
6956                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
6957                 }
6958                 case LDKParseError_InvalidSegWitProgramLength: {
6959                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
6960                 }
6961                 case LDKParseError_InvalidPubKeyHashLength: {
6962                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
6963                 }
6964                 case LDKParseError_InvalidScriptHashLength: {
6965                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
6966                 }
6967                 case LDKParseError_InvalidRecoveryId: {
6968                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
6969                 }
6970                 case LDKParseError_InvalidSliceLength: {
6971                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
6972                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
6973                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
6974                 }
6975                 case LDKParseError_Skip: {
6976                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
6977                 }
6978                 default: abort();
6979         }
6980 }
6981 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6982 CHECK(owner->result_ok);
6983         return SiPrefix_clone(&*owner->contents.result);
6984 }
6985 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6986         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6987         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
6988         return ret_conv;
6989 }
6990
6991 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
6992 CHECK(!owner->result_ok);
6993         return ParseError_clone(&*owner->contents.err);
6994 }
6995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6996         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
6997         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
6998         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
6999         int64_t ret_ref = (uintptr_t)ret_copy;
7000         return ret_ref;
7001 }
7002
7003 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
7004 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
7005 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
7006 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
7007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
7008         LDKParseOrSemanticError_ParseError_class =
7009                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
7010         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
7011         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
7012         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
7013         LDKParseOrSemanticError_SemanticError_class =
7014                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
7015         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
7016         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
7017         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
7018 }
7019 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7020         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
7021         switch(obj->tag) {
7022                 case LDKParseOrSemanticError_ParseError: {
7023                         int64_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
7024                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
7025                 }
7026                 case LDKParseOrSemanticError_SemanticError: {
7027                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
7028                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
7029                 }
7030                 default: abort();
7031         }
7032 }
7033 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7034 CHECK(owner->result_ok);
7035         return Invoice_clone(&*owner->contents.result);
7036 }
7037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7038         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7039         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
7040         int64_t ret_ref = 0;
7041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7044         ret_ref = (uintptr_t)ret_var.inner;
7045         if (ret_var.is_owned) {
7046                 ret_ref |= 1;
7047         }
7048         return ret_ref;
7049 }
7050
7051 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
7052 CHECK(!owner->result_ok);
7053         return ParseOrSemanticError_clone(&*owner->contents.err);
7054 }
7055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7056         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
7057         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
7058         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
7059         int64_t ret_ref = (uintptr_t)ret_copy;
7060         return ret_ref;
7061 }
7062
7063 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7064 CHECK(owner->result_ok);
7065         return SignedRawInvoice_clone(&*owner->contents.result);
7066 }
7067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7068         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7069         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
7070         int64_t ret_ref = 0;
7071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7074         ret_ref = (uintptr_t)ret_var.inner;
7075         if (ret_var.is_owned) {
7076                 ret_ref |= 1;
7077         }
7078         return ret_ref;
7079 }
7080
7081 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
7082 CHECK(!owner->result_ok);
7083         return ParseError_clone(&*owner->contents.err);
7084 }
7085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7086         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
7087         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
7088         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
7089         int64_t ret_ref = (uintptr_t)ret_copy;
7090         return ret_ref;
7091 }
7092
7093 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7094         return RawInvoice_clone(&owner->a);
7095 }
7096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7097         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7098         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
7099         int64_t ret_ref = 0;
7100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7103         ret_ref = (uintptr_t)ret_var.inner;
7104         if (ret_var.is_owned) {
7105                 ret_ref |= 1;
7106         }
7107         return ret_ref;
7108 }
7109
7110 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7111         return ThirtyTwoBytes_clone(&owner->b);
7112 }
7113 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7114         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7115         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7116         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
7117         return ret_arr;
7118 }
7119
7120 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
7121         return InvoiceSignature_clone(&owner->c);
7122 }
7123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7124         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
7125         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
7126         int64_t ret_ref = 0;
7127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7130         ret_ref = (uintptr_t)ret_var.inner;
7131         if (ret_var.is_owned) {
7132                 ret_ref |= 1;
7133         }
7134         return ret_ref;
7135 }
7136
7137 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7138 CHECK(owner->result_ok);
7139         return PayeePubKey_clone(&*owner->contents.result);
7140 }
7141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7142         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7143         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
7144         int64_t ret_ref = 0;
7145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7148         ret_ref = (uintptr_t)ret_var.inner;
7149         if (ret_var.is_owned) {
7150                 ret_ref |= 1;
7151         }
7152         return ret_ref;
7153 }
7154
7155 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
7156 CHECK(!owner->result_ok);
7157         return *owner->contents.err;
7158 }
7159 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7160         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
7161         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
7162         return ret_conv;
7163 }
7164
7165 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
7166         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
7167         for (size_t i = 0; i < ret.datalen; i++) {
7168                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
7169         }
7170         return ret;
7171 }
7172 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7173 CHECK(owner->result_ok);
7174         return PositiveTimestamp_clone(&*owner->contents.result);
7175 }
7176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7177         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7178         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
7179         int64_t ret_ref = 0;
7180         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7181         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7183         ret_ref = (uintptr_t)ret_var.inner;
7184         if (ret_var.is_owned) {
7185                 ret_ref |= 1;
7186         }
7187         return ret_ref;
7188 }
7189
7190 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
7191 CHECK(!owner->result_ok);
7192         return CreationError_clone(&*owner->contents.err);
7193 }
7194 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7195         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
7196         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
7197         return ret_conv;
7198 }
7199
7200 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7201 CHECK(owner->result_ok);
7202         return *owner->contents.result;
7203 }
7204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7205         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7206         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
7207 }
7208
7209 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
7210 CHECK(!owner->result_ok);
7211         return SemanticError_clone(&*owner->contents.err);
7212 }
7213 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7214         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
7215         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
7216         return ret_conv;
7217 }
7218
7219 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7220 CHECK(owner->result_ok);
7221         return Invoice_clone(&*owner->contents.result);
7222 }
7223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7224         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7225         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
7226         int64_t ret_ref = 0;
7227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7230         ret_ref = (uintptr_t)ret_var.inner;
7231         if (ret_var.is_owned) {
7232                 ret_ref |= 1;
7233         }
7234         return ret_ref;
7235 }
7236
7237 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
7238 CHECK(!owner->result_ok);
7239         return SemanticError_clone(&*owner->contents.err);
7240 }
7241 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7242         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
7243         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
7244         return ret_conv;
7245 }
7246
7247 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7248 CHECK(owner->result_ok);
7249         return Description_clone(&*owner->contents.result);
7250 }
7251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7252         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7253         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
7254         int64_t ret_ref = 0;
7255         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7256         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7258         ret_ref = (uintptr_t)ret_var.inner;
7259         if (ret_var.is_owned) {
7260                 ret_ref |= 1;
7261         }
7262         return ret_ref;
7263 }
7264
7265 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
7266 CHECK(!owner->result_ok);
7267         return CreationError_clone(&*owner->contents.err);
7268 }
7269 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7270         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
7271         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
7272         return ret_conv;
7273 }
7274
7275 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7276 CHECK(owner->result_ok);
7277         return PrivateRoute_clone(&*owner->contents.result);
7278 }
7279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7280         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
7281         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
7282         int64_t ret_ref = 0;
7283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7286         ret_ref = (uintptr_t)ret_var.inner;
7287         if (ret_var.is_owned) {
7288                 ret_ref |= 1;
7289         }
7290         return ret_ref;
7291 }
7292
7293 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
7294 CHECK(!owner->result_ok);
7295         return CreationError_clone(&*owner->contents.err);
7296 }
7297 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7298         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
7299         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
7300         return ret_conv;
7301 }
7302
7303 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7304 CHECK(owner->result_ok);
7305         return *owner->contents.result;
7306 }
7307 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7308         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
7309         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
7310         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7311         return ret_conv;
7312 }
7313
7314 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
7315 CHECK(!owner->result_ok);
7316         return *owner->contents.err;
7317 }
7318 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7319         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
7320         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
7321         return ret_conv;
7322 }
7323
7324 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
7325 CHECK(owner->result_ok);
7326         return ChannelMonitorUpdate_clone(&*owner->contents.result);
7327 }
7328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7329         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
7330         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
7331         int64_t ret_ref = 0;
7332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7335         ret_ref = (uintptr_t)ret_var.inner;
7336         if (ret_var.is_owned) {
7337                 ret_ref |= 1;
7338         }
7339         return ret_ref;
7340 }
7341
7342 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
7343 CHECK(!owner->result_ok);
7344         return DecodeError_clone(&*owner->contents.err);
7345 }
7346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7347         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
7348         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
7349         int64_t ret_ref = 0;
7350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7353         ret_ref = (uintptr_t)ret_var.inner;
7354         if (ret_var.is_owned) {
7355                 ret_ref |= 1;
7356         }
7357         return ret_ref;
7358 }
7359
7360 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
7361 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
7362 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
7363 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
7364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
7365         LDKCOption_MonitorEventZ_Some_class =
7366                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
7367         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
7368         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
7369         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
7370         LDKCOption_MonitorEventZ_None_class =
7371                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
7372         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
7373         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
7374         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
7375 }
7376 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7377         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
7378         switch(obj->tag) {
7379                 case LDKCOption_MonitorEventZ_Some: {
7380                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
7381                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
7382                 }
7383                 case LDKCOption_MonitorEventZ_None: {
7384                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
7385                 }
7386                 default: abort();
7387         }
7388 }
7389 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7390 CHECK(owner->result_ok);
7391         return COption_MonitorEventZ_clone(&*owner->contents.result);
7392 }
7393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7394         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
7395         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
7396         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
7397         int64_t ret_ref = (uintptr_t)ret_copy;
7398         return ret_ref;
7399 }
7400
7401 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7402 CHECK(!owner->result_ok);
7403         return DecodeError_clone(&*owner->contents.err);
7404 }
7405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7406         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
7407         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
7408         int64_t ret_ref = 0;
7409         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7410         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7412         ret_ref = (uintptr_t)ret_var.inner;
7413         if (ret_var.is_owned) {
7414                 ret_ref |= 1;
7415         }
7416         return ret_ref;
7417 }
7418
7419 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7420 CHECK(owner->result_ok);
7421         return HTLCUpdate_clone(&*owner->contents.result);
7422 }
7423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7424         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
7425         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
7426         int64_t ret_ref = 0;
7427         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7428         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7430         ret_ref = (uintptr_t)ret_var.inner;
7431         if (ret_var.is_owned) {
7432                 ret_ref |= 1;
7433         }
7434         return ret_ref;
7435 }
7436
7437 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7438 CHECK(!owner->result_ok);
7439         return DecodeError_clone(&*owner->contents.err);
7440 }
7441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7442         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
7443         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
7444         int64_t ret_ref = 0;
7445         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7446         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7448         ret_ref = (uintptr_t)ret_var.inner;
7449         if (ret_var.is_owned) {
7450                 ret_ref |= 1;
7451         }
7452         return ret_ref;
7453 }
7454
7455 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7456         return OutPoint_clone(&owner->a);
7457 }
7458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7459         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
7460         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
7461         int64_t ret_ref = 0;
7462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7465         ret_ref = (uintptr_t)ret_var.inner;
7466         if (ret_var.is_owned) {
7467                 ret_ref |= 1;
7468         }
7469         return ret_ref;
7470 }
7471
7472 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
7473         return CVec_u8Z_clone(&owner->b);
7474 }
7475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7476         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
7477         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
7478         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7479         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7480         CVec_u8Z_free(ret_var);
7481         return ret_arr;
7482 }
7483
7484 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7485         return owner->a;
7486 }
7487 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7488         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
7489         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
7490         return ret_conv;
7491 }
7492
7493 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
7494         return CVec_u8Z_clone(&owner->b);
7495 }
7496 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7497         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
7498         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
7499         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7500         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7501         CVec_u8Z_free(ret_var);
7502         return ret_arr;
7503 }
7504
7505 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
7506         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
7507         for (size_t i = 0; i < ret.datalen; i++) {
7508                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
7509         }
7510         return ret;
7511 }
7512 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7513         return ThirtyTwoBytes_clone(&owner->a);
7514 }
7515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7516         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
7517         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7518         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
7519         return ret_arr;
7520 }
7521
7522 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
7523         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
7524 }
7525 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7526         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
7527         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
7528         int64_tArray ret_arr = NULL;
7529         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7530         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7531         for (size_t v = 0; v < ret_var.datalen; v++) {
7532                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
7533                 *ret_conv_21_conv = ret_var.data[v];
7534                 ret_arr_ptr[v] = ((int64_t)ret_conv_21_conv);
7535         }
7536         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7537         FREE(ret_var.data);
7538         return ret_arr;
7539 }
7540
7541 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
7542         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 };
7543         for (size_t i = 0; i < ret.datalen; i++) {
7544                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
7545         }
7546         return ret;
7547 }
7548 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
7549         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
7550         for (size_t i = 0; i < ret.datalen; i++) {
7551                 ret.data[i] = Event_clone(&orig->data[i]);
7552         }
7553         return ret;
7554 }
7555 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7556         return owner->a;
7557 }
7558 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7559         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
7560         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
7561         return ret_conv;
7562 }
7563
7564 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7565         return TxOut_clone(&owner->b);
7566 }
7567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7568         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
7569         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7570         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
7571         return (int64_t)ret_ref;
7572 }
7573
7574 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
7575         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
7576         for (size_t i = 0; i < ret.datalen; i++) {
7577                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
7578         }
7579         return ret;
7580 }
7581 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7582         return ThirtyTwoBytes_clone(&owner->a);
7583 }
7584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7585         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
7586         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7587         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
7588         return ret_arr;
7589 }
7590
7591 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7592         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
7593 }
7594 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7595         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
7596         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
7597         int64_tArray ret_arr = NULL;
7598         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7599         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7600         for (size_t u = 0; u < ret_var.datalen; u++) {
7601                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7602                 *ret_conv_20_conv = ret_var.data[u];
7603                 ret_arr_ptr[u] = ((int64_t)ret_conv_20_conv);
7604         }
7605         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7606         FREE(ret_var.data);
7607         return ret_arr;
7608 }
7609
7610 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
7611         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 };
7612         for (size_t i = 0; i < ret.datalen; i++) {
7613                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
7614         }
7615         return ret;
7616 }
7617 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
7618 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
7619 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
7620 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
7621 static jclass LDKBalance_ContentiousClaimable_class = NULL;
7622 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
7623 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
7624 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
7625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
7626         LDKBalance_ClaimableOnChannelClose_class =
7627                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
7628         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
7629         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
7630         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
7631         LDKBalance_ClaimableAwaitingConfirmations_class =
7632                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
7633         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
7634         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
7635         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
7636         LDKBalance_ContentiousClaimable_class =
7637                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
7638         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
7639         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
7640         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
7641         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
7642                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout"));
7643         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
7644         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
7645         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
7646 }
7647 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7648         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
7649         switch(obj->tag) {
7650                 case LDKBalance_ClaimableOnChannelClose: {
7651                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
7652                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
7653                 }
7654                 case LDKBalance_ClaimableAwaitingConfirmations: {
7655                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
7656                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
7657                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
7658                 }
7659                 case LDKBalance_ContentiousClaimable: {
7660                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
7661                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
7662                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
7663                 }
7664                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
7665                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
7666                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
7667                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, claimable_amount_satoshis_conv, claimable_height_conv);
7668                 }
7669                 default: abort();
7670         }
7671 }
7672 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
7673         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
7674         for (size_t i = 0; i < ret.datalen; i++) {
7675                 ret.data[i] = Balance_clone(&orig->data[i]);
7676         }
7677         return ret;
7678 }
7679 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7680 CHECK(owner->result_ok);
7681         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
7682 }
7683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7684         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
7685         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
7686         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
7687         return ((int64_t)ret_conv);
7688 }
7689
7690 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7691 CHECK(!owner->result_ok);
7692         return DecodeError_clone(&*owner->contents.err);
7693 }
7694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7695         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
7696         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
7697         int64_t ret_ref = 0;
7698         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7699         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7701         ret_ref = (uintptr_t)ret_var.inner;
7702         if (ret_var.is_owned) {
7703                 ret_ref |= 1;
7704         }
7705         return ret_ref;
7706 }
7707
7708 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
7709 CHECK(owner->result_ok);
7710         return *owner->contents.result;
7711 }
7712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7713         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
7714         CResult_NoneLightningErrorZ_get_ok(owner_conv);
7715 }
7716
7717 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
7718 CHECK(!owner->result_ok);
7719         return LightningError_clone(&*owner->contents.err);
7720 }
7721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7722         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
7723         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
7724         int64_t ret_ref = 0;
7725         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7726         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7728         ret_ref = (uintptr_t)ret_var.inner;
7729         if (ret_var.is_owned) {
7730                 ret_ref |= 1;
7731         }
7732         return ret_ref;
7733 }
7734
7735 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7736         return owner->a;
7737 }
7738 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7739         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
7740         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
7741         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
7742         return ret_arr;
7743 }
7744
7745 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7746         return Type_clone(&owner->b);
7747 }
7748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7749         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
7750         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
7751         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
7752         return (int64_t)ret_ret;
7753 }
7754
7755 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
7756         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
7757         for (size_t i = 0; i < ret.datalen; i++) {
7758                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
7759         }
7760         return ret;
7761 }
7762 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
7763 CHECK(owner->result_ok);
7764         return *owner->contents.result;
7765 }
7766 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7767         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
7768         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
7769         return ret_conv;
7770 }
7771
7772 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
7773 CHECK(!owner->result_ok);
7774         return LightningError_clone(&*owner->contents.err);
7775 }
7776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7777         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
7778         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
7779         int64_t ret_ref = 0;
7780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7783         ret_ref = (uintptr_t)ret_var.inner;
7784         if (ret_var.is_owned) {
7785                 ret_ref |= 1;
7786         }
7787         return ret_ref;
7788 }
7789
7790 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7791         return ChannelAnnouncement_clone(&owner->a);
7792 }
7793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7794         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7795         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
7796         int64_t ret_ref = 0;
7797         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7798         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7800         ret_ref = (uintptr_t)ret_var.inner;
7801         if (ret_var.is_owned) {
7802                 ret_ref |= 1;
7803         }
7804         return ret_ref;
7805 }
7806
7807 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7808         return ChannelUpdate_clone(&owner->b);
7809 }
7810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7811         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7812         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
7813         int64_t ret_ref = 0;
7814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7817         ret_ref = (uintptr_t)ret_var.inner;
7818         if (ret_var.is_owned) {
7819                 ret_ref |= 1;
7820         }
7821         return ret_ref;
7822 }
7823
7824 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
7825         return ChannelUpdate_clone(&owner->c);
7826 }
7827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
7828         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
7829         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
7830         int64_t ret_ref = 0;
7831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7834         ret_ref = (uintptr_t)ret_var.inner;
7835         if (ret_var.is_owned) {
7836                 ret_ref |= 1;
7837         }
7838         return ret_ref;
7839 }
7840
7841 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
7842         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
7843         for (size_t i = 0; i < ret.datalen; i++) {
7844                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
7845         }
7846         return ret;
7847 }
7848 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
7849         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
7850         for (size_t i = 0; i < ret.datalen; i++) {
7851                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
7852         }
7853         return ret;
7854 }
7855 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
7856 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
7857 static jclass LDKCOption_NetAddressZ_None_class = NULL;
7858 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
7859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
7860         LDKCOption_NetAddressZ_Some_class =
7861                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
7862         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
7863         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
7864         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
7865         LDKCOption_NetAddressZ_None_class =
7866                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
7867         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
7868         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
7869         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
7870 }
7871 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7872         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
7873         switch(obj->tag) {
7874                 case LDKCOption_NetAddressZ_Some: {
7875                         int64_t some_ref = ((uintptr_t)&obj->some) | 1;
7876                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
7877                 }
7878                 case LDKCOption_NetAddressZ_None: {
7879                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
7880                 }
7881                 default: abort();
7882         }
7883 }
7884 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7885 CHECK(owner->result_ok);
7886         return CVec_u8Z_clone(&*owner->contents.result);
7887 }
7888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7889         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7890         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
7891         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7892         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7893         CVec_u8Z_free(ret_var);
7894         return ret_arr;
7895 }
7896
7897 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7898 CHECK(!owner->result_ok);
7899         return PeerHandleError_clone(&*owner->contents.err);
7900 }
7901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7902         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
7903         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
7904         int64_t ret_ref = 0;
7905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7908         ret_ref = (uintptr_t)ret_var.inner;
7909         if (ret_var.is_owned) {
7910                 ret_ref |= 1;
7911         }
7912         return ret_ref;
7913 }
7914
7915 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7916 CHECK(owner->result_ok);
7917         return *owner->contents.result;
7918 }
7919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7920         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7921         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
7922 }
7923
7924 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7925 CHECK(!owner->result_ok);
7926         return PeerHandleError_clone(&*owner->contents.err);
7927 }
7928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7929         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
7930         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
7931         int64_t ret_ref = 0;
7932         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7933         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7935         ret_ref = (uintptr_t)ret_var.inner;
7936         if (ret_var.is_owned) {
7937                 ret_ref |= 1;
7938         }
7939         return ret_ref;
7940 }
7941
7942 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7943 CHECK(owner->result_ok);
7944         return *owner->contents.result;
7945 }
7946 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7947         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7948         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
7949         return ret_conv;
7950 }
7951
7952 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7953 CHECK(!owner->result_ok);
7954         return PeerHandleError_clone(&*owner->contents.err);
7955 }
7956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7957         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
7958         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
7959         int64_t ret_ref = 0;
7960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7963         ret_ref = (uintptr_t)ret_var.inner;
7964         if (ret_var.is_owned) {
7965                 ret_ref |= 1;
7966         }
7967         return ret_ref;
7968 }
7969
7970 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7971 CHECK(owner->result_ok);
7972         return NodeId_clone(&*owner->contents.result);
7973 }
7974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7975         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7976         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
7977         int64_t ret_ref = 0;
7978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7981         ret_ref = (uintptr_t)ret_var.inner;
7982         if (ret_var.is_owned) {
7983                 ret_ref |= 1;
7984         }
7985         return ret_ref;
7986 }
7987
7988 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
7989 CHECK(!owner->result_ok);
7990         return DecodeError_clone(&*owner->contents.err);
7991 }
7992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7993         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
7994         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
7995         int64_t ret_ref = 0;
7996         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7997         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7999         ret_ref = (uintptr_t)ret_var.inner;
8000         if (ret_var.is_owned) {
8001                 ret_ref |= 1;
8002         }
8003         return ret_ref;
8004 }
8005
8006 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
8007 CHECK(owner->result_ok);
8008         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
8009 }
8010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8011         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
8012         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
8013         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
8014         int64_t ret_ref = (uintptr_t)ret_copy;
8015         return ret_ref;
8016 }
8017
8018 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
8019 CHECK(!owner->result_ok);
8020         return DecodeError_clone(&*owner->contents.err);
8021 }
8022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8023         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
8024         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
8025         int64_t ret_ref = 0;
8026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8029         ret_ref = (uintptr_t)ret_var.inner;
8030         if (ret_var.is_owned) {
8031                 ret_ref |= 1;
8032         }
8033         return ret_ref;
8034 }
8035
8036 typedef struct LDKAccess_JCalls {
8037         atomic_size_t refcnt;
8038         JavaVM *vm;
8039         jweak o;
8040         jmethodID get_utxo_meth;
8041 } LDKAccess_JCalls;
8042 static void LDKAccess_JCalls_free(void* this_arg) {
8043         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
8044         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8045                 JNIEnv *env;
8046                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8047                 if (get_jenv_res == JNI_EDETACHED) {
8048                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8049                 } else {
8050                         DO_ASSERT(get_jenv_res == JNI_OK);
8051                 }
8052                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8053                 if (get_jenv_res == JNI_EDETACHED) {
8054                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8055                 }
8056                 FREE(j_calls);
8057         }
8058 }
8059 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
8060         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
8061         JNIEnv *env;
8062         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8063         if (get_jenv_res == JNI_EDETACHED) {
8064                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8065         } else {
8066                 DO_ASSERT(get_jenv_res == JNI_OK);
8067         }
8068         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
8069         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
8070         int64_t short_channel_id_conv = short_channel_id;
8071         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8072         CHECK(obj != NULL);
8073         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
8074         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8075                 (*env)->ExceptionDescribe(env);
8076                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
8077         }
8078         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8079         CHECK_ACCESS(ret_ptr);
8080         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
8081         FREE((void*)ret);
8082         if (get_jenv_res == JNI_EDETACHED) {
8083                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8084         }
8085         return ret_conv;
8086 }
8087 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
8088         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
8089         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8090 }
8091 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
8092         jclass c = (*env)->GetObjectClass(env, o);
8093         CHECK(c != NULL);
8094         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
8095         atomic_init(&calls->refcnt, 1);
8096         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8097         calls->o = (*env)->NewWeakGlobalRef(env, o);
8098         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
8099         CHECK(calls->get_utxo_meth != NULL);
8100
8101         LDKAccess ret = {
8102                 .this_arg = (void*) calls,
8103                 .get_utxo = get_utxo_LDKAccess_jcall,
8104                 .free = LDKAccess_JCalls_free,
8105         };
8106         return ret;
8107 }
8108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
8109         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
8110         *res_ptr = LDKAccess_init(env, clz, o);
8111         return (uint64_t)res_ptr;
8112 }
8113 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) {
8114         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8115         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8116         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
8117         unsigned char genesis_hash_arr[32];
8118         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
8119         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
8120         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
8121         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
8122         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
8123         return (int64_t)ret_conv;
8124 }
8125
8126 static jclass LDKCOption_AccessZ_Some_class = NULL;
8127 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
8128 static jclass LDKCOption_AccessZ_None_class = NULL;
8129 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
8130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
8131         LDKCOption_AccessZ_Some_class =
8132                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
8133         CHECK(LDKCOption_AccessZ_Some_class != NULL);
8134         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
8135         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
8136         LDKCOption_AccessZ_None_class =
8137                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
8138         CHECK(LDKCOption_AccessZ_None_class != NULL);
8139         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
8140         CHECK(LDKCOption_AccessZ_None_meth != NULL);
8141 }
8142 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8143         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
8144         switch(obj->tag) {
8145                 case LDKCOption_AccessZ_Some: {
8146                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
8147                         *some_ret = obj->some;
8148                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
8149                         if ((*some_ret).free == LDKAccess_JCalls_free) {
8150                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8151                                 LDKAccess_JCalls_cloned(&(*some_ret));
8152                         }
8153                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (int64_t)some_ret);
8154                 }
8155                 case LDKCOption_AccessZ_None: {
8156                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
8157                 }
8158                 default: abort();
8159         }
8160 }
8161 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
8162 CHECK(owner->result_ok);
8163         return ChannelUpdateInfo_clone(&*owner->contents.result);
8164 }
8165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8166         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
8167         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
8168         int64_t ret_ref = 0;
8169         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8170         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8172         ret_ref = (uintptr_t)ret_var.inner;
8173         if (ret_var.is_owned) {
8174                 ret_ref |= 1;
8175         }
8176         return ret_ref;
8177 }
8178
8179 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
8180 CHECK(!owner->result_ok);
8181         return DecodeError_clone(&*owner->contents.err);
8182 }
8183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8184         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
8185         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
8186         int64_t ret_ref = 0;
8187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8190         ret_ref = (uintptr_t)ret_var.inner;
8191         if (ret_var.is_owned) {
8192                 ret_ref |= 1;
8193         }
8194         return ret_ref;
8195 }
8196
8197 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
8198 CHECK(owner->result_ok);
8199         return ChannelInfo_clone(&*owner->contents.result);
8200 }
8201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8202         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
8203         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
8204         int64_t ret_ref = 0;
8205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8208         ret_ref = (uintptr_t)ret_var.inner;
8209         if (ret_var.is_owned) {
8210                 ret_ref |= 1;
8211         }
8212         return ret_ref;
8213 }
8214
8215 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
8216 CHECK(!owner->result_ok);
8217         return DecodeError_clone(&*owner->contents.err);
8218 }
8219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8220         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
8221         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
8222         int64_t ret_ref = 0;
8223         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8224         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8226         ret_ref = (uintptr_t)ret_var.inner;
8227         if (ret_var.is_owned) {
8228                 ret_ref |= 1;
8229         }
8230         return ret_ref;
8231 }
8232
8233 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
8234 CHECK(owner->result_ok);
8235         return RoutingFees_clone(&*owner->contents.result);
8236 }
8237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8238         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
8239         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
8240         int64_t ret_ref = 0;
8241         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8242         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8244         ret_ref = (uintptr_t)ret_var.inner;
8245         if (ret_var.is_owned) {
8246                 ret_ref |= 1;
8247         }
8248         return ret_ref;
8249 }
8250
8251 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
8252 CHECK(!owner->result_ok);
8253         return DecodeError_clone(&*owner->contents.err);
8254 }
8255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8256         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
8257         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
8258         int64_t ret_ref = 0;
8259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8262         ret_ref = (uintptr_t)ret_var.inner;
8263         if (ret_var.is_owned) {
8264                 ret_ref |= 1;
8265         }
8266         return ret_ref;
8267 }
8268
8269 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
8270 CHECK(owner->result_ok);
8271         return NodeAnnouncementInfo_clone(&*owner->contents.result);
8272 }
8273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8274         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
8275         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
8276         int64_t ret_ref = 0;
8277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8280         ret_ref = (uintptr_t)ret_var.inner;
8281         if (ret_var.is_owned) {
8282                 ret_ref |= 1;
8283         }
8284         return ret_ref;
8285 }
8286
8287 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
8288 CHECK(!owner->result_ok);
8289         return DecodeError_clone(&*owner->contents.err);
8290 }
8291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8292         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
8293         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
8294         int64_t ret_ref = 0;
8295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8298         ret_ref = (uintptr_t)ret_var.inner;
8299         if (ret_var.is_owned) {
8300                 ret_ref |= 1;
8301         }
8302         return ret_ref;
8303 }
8304
8305 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
8306         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
8307         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
8308         return ret;
8309 }
8310 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
8311 CHECK(owner->result_ok);
8312         return NodeInfo_clone(&*owner->contents.result);
8313 }
8314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8315         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
8316         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
8317         int64_t ret_ref = 0;
8318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8321         ret_ref = (uintptr_t)ret_var.inner;
8322         if (ret_var.is_owned) {
8323                 ret_ref |= 1;
8324         }
8325         return ret_ref;
8326 }
8327
8328 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
8329 CHECK(!owner->result_ok);
8330         return DecodeError_clone(&*owner->contents.err);
8331 }
8332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8333         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
8334         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
8335         int64_t ret_ref = 0;
8336         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8337         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8339         ret_ref = (uintptr_t)ret_var.inner;
8340         if (ret_var.is_owned) {
8341                 ret_ref |= 1;
8342         }
8343         return ret_ref;
8344 }
8345
8346 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
8347 CHECK(owner->result_ok);
8348         return NetworkGraph_clone(&*owner->contents.result);
8349 }
8350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8351         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
8352         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
8353         int64_t ret_ref = 0;
8354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8357         ret_ref = (uintptr_t)ret_var.inner;
8358         if (ret_var.is_owned) {
8359                 ret_ref |= 1;
8360         }
8361         return ret_ref;
8362 }
8363
8364 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
8365 CHECK(!owner->result_ok);
8366         return DecodeError_clone(&*owner->contents.err);
8367 }
8368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8369         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
8370         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
8371         int64_t ret_ref = 0;
8372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8375         ret_ref = (uintptr_t)ret_var.inner;
8376         if (ret_var.is_owned) {
8377                 ret_ref |= 1;
8378         }
8379         return ret_ref;
8380 }
8381
8382 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
8383 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
8384 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
8385 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
8386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
8387         LDKCOption_CVec_NetAddressZZ_Some_class =
8388                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
8389         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
8390         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
8391         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
8392         LDKCOption_CVec_NetAddressZZ_None_class =
8393                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
8394         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
8395         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
8396         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
8397 }
8398 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8399         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
8400         switch(obj->tag) {
8401                 case LDKCOption_CVec_NetAddressZZ_Some: {
8402                         LDKCVec_NetAddressZ some_var = obj->some;
8403                         int64_tArray some_arr = NULL;
8404                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
8405                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
8406                         for (size_t m = 0; m < some_var.datalen; m++) {
8407                                 int64_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
8408                                 some_arr_ptr[m] = some_conv_12_ref;
8409                         }
8410                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
8411                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
8412                 }
8413                 case LDKCOption_CVec_NetAddressZZ_None: {
8414                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
8415                 }
8416                 default: abort();
8417         }
8418 }
8419 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8420 CHECK(owner->result_ok);
8421         return NetAddress_clone(&*owner->contents.result);
8422 }
8423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8424         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8425         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
8426         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
8427         int64_t ret_ref = (uintptr_t)ret_copy;
8428         return ret_ref;
8429 }
8430
8431 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
8432 CHECK(!owner->result_ok);
8433         return DecodeError_clone(&*owner->contents.err);
8434 }
8435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8436         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
8437         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
8438         int64_t ret_ref = 0;
8439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8442         ret_ref = (uintptr_t)ret_var.inner;
8443         if (ret_var.is_owned) {
8444                 ret_ref |= 1;
8445         }
8446         return ret_ref;
8447 }
8448
8449 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8450         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8451         for (size_t i = 0; i < ret.datalen; i++) {
8452                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8453         }
8454         return ret;
8455 }
8456 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8457         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8458         for (size_t i = 0; i < ret.datalen; i++) {
8459                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8460         }
8461         return ret;
8462 }
8463 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8464         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8465         for (size_t i = 0; i < ret.datalen; i++) {
8466                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8467         }
8468         return ret;
8469 }
8470 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8471         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8472         for (size_t i = 0; i < ret.datalen; i++) {
8473                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8474         }
8475         return ret;
8476 }
8477 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8478 CHECK(owner->result_ok);
8479         return AcceptChannel_clone(&*owner->contents.result);
8480 }
8481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8482         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8483         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8484         int64_t ret_ref = 0;
8485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8488         ret_ref = (uintptr_t)ret_var.inner;
8489         if (ret_var.is_owned) {
8490                 ret_ref |= 1;
8491         }
8492         return ret_ref;
8493 }
8494
8495 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8496 CHECK(!owner->result_ok);
8497         return DecodeError_clone(&*owner->contents.err);
8498 }
8499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8500         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
8501         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8502         int64_t ret_ref = 0;
8503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8506         ret_ref = (uintptr_t)ret_var.inner;
8507         if (ret_var.is_owned) {
8508                 ret_ref |= 1;
8509         }
8510         return ret_ref;
8511 }
8512
8513 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8514 CHECK(owner->result_ok);
8515         return AnnouncementSignatures_clone(&*owner->contents.result);
8516 }
8517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8518         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8519         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8520         int64_t ret_ref = 0;
8521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8524         ret_ref = (uintptr_t)ret_var.inner;
8525         if (ret_var.is_owned) {
8526                 ret_ref |= 1;
8527         }
8528         return ret_ref;
8529 }
8530
8531 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8532 CHECK(!owner->result_ok);
8533         return DecodeError_clone(&*owner->contents.err);
8534 }
8535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8536         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
8537         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8538         int64_t ret_ref = 0;
8539         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8540         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8542         ret_ref = (uintptr_t)ret_var.inner;
8543         if (ret_var.is_owned) {
8544                 ret_ref |= 1;
8545         }
8546         return ret_ref;
8547 }
8548
8549 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8550 CHECK(owner->result_ok);
8551         return ChannelReestablish_clone(&*owner->contents.result);
8552 }
8553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8554         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8555         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8556         int64_t ret_ref = 0;
8557         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8558         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8560         ret_ref = (uintptr_t)ret_var.inner;
8561         if (ret_var.is_owned) {
8562                 ret_ref |= 1;
8563         }
8564         return ret_ref;
8565 }
8566
8567 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8568 CHECK(!owner->result_ok);
8569         return DecodeError_clone(&*owner->contents.err);
8570 }
8571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8572         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
8573         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8574         int64_t ret_ref = 0;
8575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8578         ret_ref = (uintptr_t)ret_var.inner;
8579         if (ret_var.is_owned) {
8580                 ret_ref |= 1;
8581         }
8582         return ret_ref;
8583 }
8584
8585 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8586 CHECK(owner->result_ok);
8587         return ClosingSigned_clone(&*owner->contents.result);
8588 }
8589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8590         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8591         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8592         int64_t ret_ref = 0;
8593         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8594         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8596         ret_ref = (uintptr_t)ret_var.inner;
8597         if (ret_var.is_owned) {
8598                 ret_ref |= 1;
8599         }
8600         return ret_ref;
8601 }
8602
8603 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8604 CHECK(!owner->result_ok);
8605         return DecodeError_clone(&*owner->contents.err);
8606 }
8607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8608         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
8609         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
8610         int64_t ret_ref = 0;
8611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8614         ret_ref = (uintptr_t)ret_var.inner;
8615         if (ret_var.is_owned) {
8616                 ret_ref |= 1;
8617         }
8618         return ret_ref;
8619 }
8620
8621 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8622 CHECK(owner->result_ok);
8623         return ClosingSignedFeeRange_clone(&*owner->contents.result);
8624 }
8625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8626         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8627         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
8628         int64_t ret_ref = 0;
8629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8632         ret_ref = (uintptr_t)ret_var.inner;
8633         if (ret_var.is_owned) {
8634                 ret_ref |= 1;
8635         }
8636         return ret_ref;
8637 }
8638
8639 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8640 CHECK(!owner->result_ok);
8641         return DecodeError_clone(&*owner->contents.err);
8642 }
8643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8644         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
8645         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
8646         int64_t ret_ref = 0;
8647         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8648         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8650         ret_ref = (uintptr_t)ret_var.inner;
8651         if (ret_var.is_owned) {
8652                 ret_ref |= 1;
8653         }
8654         return ret_ref;
8655 }
8656
8657 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8658 CHECK(owner->result_ok);
8659         return CommitmentSigned_clone(&*owner->contents.result);
8660 }
8661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8662         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8663         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
8664         int64_t ret_ref = 0;
8665         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8666         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8668         ret_ref = (uintptr_t)ret_var.inner;
8669         if (ret_var.is_owned) {
8670                 ret_ref |= 1;
8671         }
8672         return ret_ref;
8673 }
8674
8675 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8676 CHECK(!owner->result_ok);
8677         return DecodeError_clone(&*owner->contents.err);
8678 }
8679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8680         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
8681         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
8682         int64_t ret_ref = 0;
8683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8686         ret_ref = (uintptr_t)ret_var.inner;
8687         if (ret_var.is_owned) {
8688                 ret_ref |= 1;
8689         }
8690         return ret_ref;
8691 }
8692
8693 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8694 CHECK(owner->result_ok);
8695         return FundingCreated_clone(&*owner->contents.result);
8696 }
8697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8698         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8699         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
8700         int64_t ret_ref = 0;
8701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8704         ret_ref = (uintptr_t)ret_var.inner;
8705         if (ret_var.is_owned) {
8706                 ret_ref |= 1;
8707         }
8708         return ret_ref;
8709 }
8710
8711 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8712 CHECK(!owner->result_ok);
8713         return DecodeError_clone(&*owner->contents.err);
8714 }
8715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8716         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
8717         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
8718         int64_t ret_ref = 0;
8719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8722         ret_ref = (uintptr_t)ret_var.inner;
8723         if (ret_var.is_owned) {
8724                 ret_ref |= 1;
8725         }
8726         return ret_ref;
8727 }
8728
8729 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8730 CHECK(owner->result_ok);
8731         return FundingSigned_clone(&*owner->contents.result);
8732 }
8733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8734         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8735         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
8736         int64_t ret_ref = 0;
8737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8740         ret_ref = (uintptr_t)ret_var.inner;
8741         if (ret_var.is_owned) {
8742                 ret_ref |= 1;
8743         }
8744         return ret_ref;
8745 }
8746
8747 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8748 CHECK(!owner->result_ok);
8749         return DecodeError_clone(&*owner->contents.err);
8750 }
8751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8752         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
8753         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
8754         int64_t ret_ref = 0;
8755         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8756         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8758         ret_ref = (uintptr_t)ret_var.inner;
8759         if (ret_var.is_owned) {
8760                 ret_ref |= 1;
8761         }
8762         return ret_ref;
8763 }
8764
8765 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
8766 CHECK(owner->result_ok);
8767         return FundingLocked_clone(&*owner->contents.result);
8768 }
8769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8770         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
8771         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
8772         int64_t ret_ref = 0;
8773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8776         ret_ref = (uintptr_t)ret_var.inner;
8777         if (ret_var.is_owned) {
8778                 ret_ref |= 1;
8779         }
8780         return ret_ref;
8781 }
8782
8783 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
8784 CHECK(!owner->result_ok);
8785         return DecodeError_clone(&*owner->contents.err);
8786 }
8787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8788         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
8789         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
8790         int64_t ret_ref = 0;
8791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8794         ret_ref = (uintptr_t)ret_var.inner;
8795         if (ret_var.is_owned) {
8796                 ret_ref |= 1;
8797         }
8798         return ret_ref;
8799 }
8800
8801 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8802 CHECK(owner->result_ok);
8803         return Init_clone(&*owner->contents.result);
8804 }
8805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8806         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8807         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
8808         int64_t ret_ref = 0;
8809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8812         ret_ref = (uintptr_t)ret_var.inner;
8813         if (ret_var.is_owned) {
8814                 ret_ref |= 1;
8815         }
8816         return ret_ref;
8817 }
8818
8819 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8820 CHECK(!owner->result_ok);
8821         return DecodeError_clone(&*owner->contents.err);
8822 }
8823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8824         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
8825         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
8826         int64_t ret_ref = 0;
8827         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8828         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8830         ret_ref = (uintptr_t)ret_var.inner;
8831         if (ret_var.is_owned) {
8832                 ret_ref |= 1;
8833         }
8834         return ret_ref;
8835 }
8836
8837 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8838 CHECK(owner->result_ok);
8839         return OpenChannel_clone(&*owner->contents.result);
8840 }
8841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8842         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8843         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
8844         int64_t ret_ref = 0;
8845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8848         ret_ref = (uintptr_t)ret_var.inner;
8849         if (ret_var.is_owned) {
8850                 ret_ref |= 1;
8851         }
8852         return ret_ref;
8853 }
8854
8855 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8856 CHECK(!owner->result_ok);
8857         return DecodeError_clone(&*owner->contents.err);
8858 }
8859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8860         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
8861         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
8862         int64_t ret_ref = 0;
8863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8866         ret_ref = (uintptr_t)ret_var.inner;
8867         if (ret_var.is_owned) {
8868                 ret_ref |= 1;
8869         }
8870         return ret_ref;
8871 }
8872
8873 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8874 CHECK(owner->result_ok);
8875         return RevokeAndACK_clone(&*owner->contents.result);
8876 }
8877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8878         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8879         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
8880         int64_t ret_ref = 0;
8881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8884         ret_ref = (uintptr_t)ret_var.inner;
8885         if (ret_var.is_owned) {
8886                 ret_ref |= 1;
8887         }
8888         return ret_ref;
8889 }
8890
8891 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8892 CHECK(!owner->result_ok);
8893         return DecodeError_clone(&*owner->contents.err);
8894 }
8895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8896         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
8897         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
8898         int64_t ret_ref = 0;
8899         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8900         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8902         ret_ref = (uintptr_t)ret_var.inner;
8903         if (ret_var.is_owned) {
8904                 ret_ref |= 1;
8905         }
8906         return ret_ref;
8907 }
8908
8909 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8910 CHECK(owner->result_ok);
8911         return Shutdown_clone(&*owner->contents.result);
8912 }
8913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8914         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8915         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
8916         int64_t ret_ref = 0;
8917         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8918         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8920         ret_ref = (uintptr_t)ret_var.inner;
8921         if (ret_var.is_owned) {
8922                 ret_ref |= 1;
8923         }
8924         return ret_ref;
8925 }
8926
8927 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8928 CHECK(!owner->result_ok);
8929         return DecodeError_clone(&*owner->contents.err);
8930 }
8931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8932         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
8933         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
8934         int64_t ret_ref = 0;
8935         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8936         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8938         ret_ref = (uintptr_t)ret_var.inner;
8939         if (ret_var.is_owned) {
8940                 ret_ref |= 1;
8941         }
8942         return ret_ref;
8943 }
8944
8945 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8946 CHECK(owner->result_ok);
8947         return UpdateFailHTLC_clone(&*owner->contents.result);
8948 }
8949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8950         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8951         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
8952         int64_t ret_ref = 0;
8953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8956         ret_ref = (uintptr_t)ret_var.inner;
8957         if (ret_var.is_owned) {
8958                 ret_ref |= 1;
8959         }
8960         return ret_ref;
8961 }
8962
8963 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8964 CHECK(!owner->result_ok);
8965         return DecodeError_clone(&*owner->contents.err);
8966 }
8967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8968         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
8969         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
8970         int64_t ret_ref = 0;
8971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8974         ret_ref = (uintptr_t)ret_var.inner;
8975         if (ret_var.is_owned) {
8976                 ret_ref |= 1;
8977         }
8978         return ret_ref;
8979 }
8980
8981 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8982 CHECK(owner->result_ok);
8983         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
8984 }
8985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8986         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
8987         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
8988         int64_t ret_ref = 0;
8989         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8990         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8992         ret_ref = (uintptr_t)ret_var.inner;
8993         if (ret_var.is_owned) {
8994                 ret_ref |= 1;
8995         }
8996         return ret_ref;
8997 }
8998
8999 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9000 CHECK(!owner->result_ok);
9001         return DecodeError_clone(&*owner->contents.err);
9002 }
9003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9004         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
9005         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
9006         int64_t ret_ref = 0;
9007         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9008         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9010         ret_ref = (uintptr_t)ret_var.inner;
9011         if (ret_var.is_owned) {
9012                 ret_ref |= 1;
9013         }
9014         return ret_ref;
9015 }
9016
9017 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9018 CHECK(owner->result_ok);
9019         return UpdateFee_clone(&*owner->contents.result);
9020 }
9021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9022         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9023         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
9024         int64_t ret_ref = 0;
9025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9028         ret_ref = (uintptr_t)ret_var.inner;
9029         if (ret_var.is_owned) {
9030                 ret_ref |= 1;
9031         }
9032         return ret_ref;
9033 }
9034
9035 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9036 CHECK(!owner->result_ok);
9037         return DecodeError_clone(&*owner->contents.err);
9038 }
9039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9040         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
9041         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9042         int64_t ret_ref = 0;
9043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9046         ret_ref = (uintptr_t)ret_var.inner;
9047         if (ret_var.is_owned) {
9048                 ret_ref |= 1;
9049         }
9050         return ret_ref;
9051 }
9052
9053 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9054 CHECK(owner->result_ok);
9055         return UpdateFulfillHTLC_clone(&*owner->contents.result);
9056 }
9057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9058         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9059         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9060         int64_t ret_ref = 0;
9061         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9062         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9064         ret_ref = (uintptr_t)ret_var.inner;
9065         if (ret_var.is_owned) {
9066                 ret_ref |= 1;
9067         }
9068         return ret_ref;
9069 }
9070
9071 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9072 CHECK(!owner->result_ok);
9073         return DecodeError_clone(&*owner->contents.err);
9074 }
9075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9076         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
9077         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9078         int64_t ret_ref = 0;
9079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9082         ret_ref = (uintptr_t)ret_var.inner;
9083         if (ret_var.is_owned) {
9084                 ret_ref |= 1;
9085         }
9086         return ret_ref;
9087 }
9088
9089 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9090 CHECK(owner->result_ok);
9091         return UpdateAddHTLC_clone(&*owner->contents.result);
9092 }
9093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9094         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9095         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9096         int64_t ret_ref = 0;
9097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9100         ret_ref = (uintptr_t)ret_var.inner;
9101         if (ret_var.is_owned) {
9102                 ret_ref |= 1;
9103         }
9104         return ret_ref;
9105 }
9106
9107 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9108 CHECK(!owner->result_ok);
9109         return DecodeError_clone(&*owner->contents.err);
9110 }
9111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9112         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
9113         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9114         int64_t ret_ref = 0;
9115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9118         ret_ref = (uintptr_t)ret_var.inner;
9119         if (ret_var.is_owned) {
9120                 ret_ref |= 1;
9121         }
9122         return ret_ref;
9123 }
9124
9125 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9126 CHECK(owner->result_ok);
9127         return Ping_clone(&*owner->contents.result);
9128 }
9129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9130         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9131         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9132         int64_t ret_ref = 0;
9133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9136         ret_ref = (uintptr_t)ret_var.inner;
9137         if (ret_var.is_owned) {
9138                 ret_ref |= 1;
9139         }
9140         return ret_ref;
9141 }
9142
9143 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9144 CHECK(!owner->result_ok);
9145         return DecodeError_clone(&*owner->contents.err);
9146 }
9147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9148         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
9149         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
9150         int64_t ret_ref = 0;
9151         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9152         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9154         ret_ref = (uintptr_t)ret_var.inner;
9155         if (ret_var.is_owned) {
9156                 ret_ref |= 1;
9157         }
9158         return ret_ref;
9159 }
9160
9161 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9162 CHECK(owner->result_ok);
9163         return Pong_clone(&*owner->contents.result);
9164 }
9165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9166         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9167         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9168         int64_t ret_ref = 0;
9169         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9170         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9172         ret_ref = (uintptr_t)ret_var.inner;
9173         if (ret_var.is_owned) {
9174                 ret_ref |= 1;
9175         }
9176         return ret_ref;
9177 }
9178
9179 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9180 CHECK(!owner->result_ok);
9181         return DecodeError_clone(&*owner->contents.err);
9182 }
9183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9184         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
9185         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
9186         int64_t ret_ref = 0;
9187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9190         ret_ref = (uintptr_t)ret_var.inner;
9191         if (ret_var.is_owned) {
9192                 ret_ref |= 1;
9193         }
9194         return ret_ref;
9195 }
9196
9197 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9198 CHECK(owner->result_ok);
9199         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
9200 }
9201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9202         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9203         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9204         int64_t ret_ref = 0;
9205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9208         ret_ref = (uintptr_t)ret_var.inner;
9209         if (ret_var.is_owned) {
9210                 ret_ref |= 1;
9211         }
9212         return ret_ref;
9213 }
9214
9215 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9216 CHECK(!owner->result_ok);
9217         return DecodeError_clone(&*owner->contents.err);
9218 }
9219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9220         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9221         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9222         int64_t ret_ref = 0;
9223         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9224         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9226         ret_ref = (uintptr_t)ret_var.inner;
9227         if (ret_var.is_owned) {
9228                 ret_ref |= 1;
9229         }
9230         return ret_ref;
9231 }
9232
9233 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9234 CHECK(owner->result_ok);
9235         return ChannelAnnouncement_clone(&*owner->contents.result);
9236 }
9237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9238         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9239         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9240         int64_t ret_ref = 0;
9241         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9242         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9244         ret_ref = (uintptr_t)ret_var.inner;
9245         if (ret_var.is_owned) {
9246                 ret_ref |= 1;
9247         }
9248         return ret_ref;
9249 }
9250
9251 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9252 CHECK(!owner->result_ok);
9253         return DecodeError_clone(&*owner->contents.err);
9254 }
9255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9256         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
9257         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9258         int64_t ret_ref = 0;
9259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9262         ret_ref = (uintptr_t)ret_var.inner;
9263         if (ret_var.is_owned) {
9264                 ret_ref |= 1;
9265         }
9266         return ret_ref;
9267 }
9268
9269 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9270 CHECK(owner->result_ok);
9271         return UnsignedChannelUpdate_clone(&*owner->contents.result);
9272 }
9273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9274         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9275         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9276         int64_t ret_ref = 0;
9277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9280         ret_ref = (uintptr_t)ret_var.inner;
9281         if (ret_var.is_owned) {
9282                 ret_ref |= 1;
9283         }
9284         return ret_ref;
9285 }
9286
9287 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9288 CHECK(!owner->result_ok);
9289         return DecodeError_clone(&*owner->contents.err);
9290 }
9291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9292         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
9293         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
9294         int64_t ret_ref = 0;
9295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9298         ret_ref = (uintptr_t)ret_var.inner;
9299         if (ret_var.is_owned) {
9300                 ret_ref |= 1;
9301         }
9302         return ret_ref;
9303 }
9304
9305 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9306 CHECK(owner->result_ok);
9307         return ChannelUpdate_clone(&*owner->contents.result);
9308 }
9309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9310         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9311         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9312         int64_t ret_ref = 0;
9313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9316         ret_ref = (uintptr_t)ret_var.inner;
9317         if (ret_var.is_owned) {
9318                 ret_ref |= 1;
9319         }
9320         return ret_ref;
9321 }
9322
9323 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9324 CHECK(!owner->result_ok);
9325         return DecodeError_clone(&*owner->contents.err);
9326 }
9327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9328         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
9329         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9330         int64_t ret_ref = 0;
9331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9334         ret_ref = (uintptr_t)ret_var.inner;
9335         if (ret_var.is_owned) {
9336                 ret_ref |= 1;
9337         }
9338         return ret_ref;
9339 }
9340
9341 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9342 CHECK(owner->result_ok);
9343         return ErrorMessage_clone(&*owner->contents.result);
9344 }
9345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9346         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9347         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9348         int64_t ret_ref = 0;
9349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9352         ret_ref = (uintptr_t)ret_var.inner;
9353         if (ret_var.is_owned) {
9354                 ret_ref |= 1;
9355         }
9356         return ret_ref;
9357 }
9358
9359 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9360 CHECK(!owner->result_ok);
9361         return DecodeError_clone(&*owner->contents.err);
9362 }
9363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9364         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
9365         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9366         int64_t ret_ref = 0;
9367         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9368         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9370         ret_ref = (uintptr_t)ret_var.inner;
9371         if (ret_var.is_owned) {
9372                 ret_ref |= 1;
9373         }
9374         return ret_ref;
9375 }
9376
9377 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9378 CHECK(owner->result_ok);
9379         return WarningMessage_clone(&*owner->contents.result);
9380 }
9381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9382         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9383         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9384         int64_t ret_ref = 0;
9385         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9386         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9388         ret_ref = (uintptr_t)ret_var.inner;
9389         if (ret_var.is_owned) {
9390                 ret_ref |= 1;
9391         }
9392         return ret_ref;
9393 }
9394
9395 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9396 CHECK(!owner->result_ok);
9397         return DecodeError_clone(&*owner->contents.err);
9398 }
9399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9400         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
9401         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9402         int64_t ret_ref = 0;
9403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9406         ret_ref = (uintptr_t)ret_var.inner;
9407         if (ret_var.is_owned) {
9408                 ret_ref |= 1;
9409         }
9410         return ret_ref;
9411 }
9412
9413 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9414 CHECK(owner->result_ok);
9415         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
9416 }
9417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9418         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9419         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9420         int64_t ret_ref = 0;
9421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9424         ret_ref = (uintptr_t)ret_var.inner;
9425         if (ret_var.is_owned) {
9426                 ret_ref |= 1;
9427         }
9428         return ret_ref;
9429 }
9430
9431 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9432 CHECK(!owner->result_ok);
9433         return DecodeError_clone(&*owner->contents.err);
9434 }
9435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9436         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
9437         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9438         int64_t ret_ref = 0;
9439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9442         ret_ref = (uintptr_t)ret_var.inner;
9443         if (ret_var.is_owned) {
9444                 ret_ref |= 1;
9445         }
9446         return ret_ref;
9447 }
9448
9449 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9450 CHECK(owner->result_ok);
9451         return NodeAnnouncement_clone(&*owner->contents.result);
9452 }
9453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9454         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9455         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9456         int64_t ret_ref = 0;
9457         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9458         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9460         ret_ref = (uintptr_t)ret_var.inner;
9461         if (ret_var.is_owned) {
9462                 ret_ref |= 1;
9463         }
9464         return ret_ref;
9465 }
9466
9467 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9468 CHECK(!owner->result_ok);
9469         return DecodeError_clone(&*owner->contents.err);
9470 }
9471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9472         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
9473         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9474         int64_t ret_ref = 0;
9475         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9476         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9478         ret_ref = (uintptr_t)ret_var.inner;
9479         if (ret_var.is_owned) {
9480                 ret_ref |= 1;
9481         }
9482         return ret_ref;
9483 }
9484
9485 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9486 CHECK(owner->result_ok);
9487         return QueryShortChannelIds_clone(&*owner->contents.result);
9488 }
9489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9490         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9491         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9492         int64_t ret_ref = 0;
9493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9496         ret_ref = (uintptr_t)ret_var.inner;
9497         if (ret_var.is_owned) {
9498                 ret_ref |= 1;
9499         }
9500         return ret_ref;
9501 }
9502
9503 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9504 CHECK(!owner->result_ok);
9505         return DecodeError_clone(&*owner->contents.err);
9506 }
9507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9508         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
9509         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9510         int64_t ret_ref = 0;
9511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9514         ret_ref = (uintptr_t)ret_var.inner;
9515         if (ret_var.is_owned) {
9516                 ret_ref |= 1;
9517         }
9518         return ret_ref;
9519 }
9520
9521 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9522 CHECK(owner->result_ok);
9523         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
9524 }
9525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9526         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9527         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9528         int64_t ret_ref = 0;
9529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9532         ret_ref = (uintptr_t)ret_var.inner;
9533         if (ret_var.is_owned) {
9534                 ret_ref |= 1;
9535         }
9536         return ret_ref;
9537 }
9538
9539 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9540 CHECK(!owner->result_ok);
9541         return DecodeError_clone(&*owner->contents.err);
9542 }
9543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9544         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
9545         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9546         int64_t ret_ref = 0;
9547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9550         ret_ref = (uintptr_t)ret_var.inner;
9551         if (ret_var.is_owned) {
9552                 ret_ref |= 1;
9553         }
9554         return ret_ref;
9555 }
9556
9557 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9558 CHECK(owner->result_ok);
9559         return QueryChannelRange_clone(&*owner->contents.result);
9560 }
9561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9562         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9563         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9564         int64_t ret_ref = 0;
9565         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9566         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9568         ret_ref = (uintptr_t)ret_var.inner;
9569         if (ret_var.is_owned) {
9570                 ret_ref |= 1;
9571         }
9572         return ret_ref;
9573 }
9574
9575 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9576 CHECK(!owner->result_ok);
9577         return DecodeError_clone(&*owner->contents.err);
9578 }
9579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9580         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
9581         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9582         int64_t ret_ref = 0;
9583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9586         ret_ref = (uintptr_t)ret_var.inner;
9587         if (ret_var.is_owned) {
9588                 ret_ref |= 1;
9589         }
9590         return ret_ref;
9591 }
9592
9593 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9594 CHECK(owner->result_ok);
9595         return ReplyChannelRange_clone(&*owner->contents.result);
9596 }
9597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9598         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9599         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9600         int64_t ret_ref = 0;
9601         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9602         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9604         ret_ref = (uintptr_t)ret_var.inner;
9605         if (ret_var.is_owned) {
9606                 ret_ref |= 1;
9607         }
9608         return ret_ref;
9609 }
9610
9611 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9612 CHECK(!owner->result_ok);
9613         return DecodeError_clone(&*owner->contents.err);
9614 }
9615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9616         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
9617         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
9618         int64_t ret_ref = 0;
9619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9622         ret_ref = (uintptr_t)ret_var.inner;
9623         if (ret_var.is_owned) {
9624                 ret_ref |= 1;
9625         }
9626         return ret_ref;
9627 }
9628
9629 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9630 CHECK(owner->result_ok);
9631         return GossipTimestampFilter_clone(&*owner->contents.result);
9632 }
9633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9634         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9635         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
9636         int64_t ret_ref = 0;
9637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9640         ret_ref = (uintptr_t)ret_var.inner;
9641         if (ret_var.is_owned) {
9642                 ret_ref |= 1;
9643         }
9644         return ret_ref;
9645 }
9646
9647 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9648 CHECK(!owner->result_ok);
9649         return DecodeError_clone(&*owner->contents.err);
9650 }
9651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9652         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
9653         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
9654         int64_t ret_ref = 0;
9655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9658         ret_ref = (uintptr_t)ret_var.inner;
9659         if (ret_var.is_owned) {
9660                 ret_ref |= 1;
9661         }
9662         return ret_ref;
9663 }
9664
9665 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
9666         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
9667         for (size_t i = 0; i < ret.datalen; i++) {
9668                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
9669         }
9670         return ret;
9671 }
9672 static jclass LDKSignOrCreationError_SignError_class = NULL;
9673 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
9674 static jclass LDKSignOrCreationError_CreationError_class = NULL;
9675 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
9676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
9677         LDKSignOrCreationError_SignError_class =
9678                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
9679         CHECK(LDKSignOrCreationError_SignError_class != NULL);
9680         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
9681         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
9682         LDKSignOrCreationError_CreationError_class =
9683                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
9684         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
9685         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
9686         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
9687 }
9688 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9689         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
9690         switch(obj->tag) {
9691                 case LDKSignOrCreationError_SignError: {
9692                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
9693                 }
9694                 case LDKSignOrCreationError_CreationError: {
9695                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
9696                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
9697                 }
9698                 default: abort();
9699         }
9700 }
9701 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9702 CHECK(owner->result_ok);
9703         return Invoice_clone(&*owner->contents.result);
9704 }
9705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9706         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9707         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
9708         int64_t ret_ref = 0;
9709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9712         ret_ref = (uintptr_t)ret_var.inner;
9713         if (ret_var.is_owned) {
9714                 ret_ref |= 1;
9715         }
9716         return ret_ref;
9717 }
9718
9719 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9720 CHECK(!owner->result_ok);
9721         return SignOrCreationError_clone(&*owner->contents.err);
9722 }
9723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9724         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
9725         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
9726         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
9727         int64_t ret_ref = (uintptr_t)ret_copy;
9728         return ret_ref;
9729 }
9730
9731 typedef struct LDKFilter_JCalls {
9732         atomic_size_t refcnt;
9733         JavaVM *vm;
9734         jweak o;
9735         jmethodID register_tx_meth;
9736         jmethodID register_output_meth;
9737 } LDKFilter_JCalls;
9738 static void LDKFilter_JCalls_free(void* this_arg) {
9739         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9740         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9741                 JNIEnv *env;
9742                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9743                 if (get_jenv_res == JNI_EDETACHED) {
9744                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9745                 } else {
9746                         DO_ASSERT(get_jenv_res == JNI_OK);
9747                 }
9748                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9749                 if (get_jenv_res == JNI_EDETACHED) {
9750                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9751                 }
9752                 FREE(j_calls);
9753         }
9754 }
9755 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
9756         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9757         JNIEnv *env;
9758         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9759         if (get_jenv_res == JNI_EDETACHED) {
9760                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9761         } else {
9762                 DO_ASSERT(get_jenv_res == JNI_OK);
9763         }
9764         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
9765         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
9766         LDKu8slice script_pubkey_var = script_pubkey;
9767         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
9768         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
9769         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9770         CHECK(obj != NULL);
9771         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
9772         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9773                 (*env)->ExceptionDescribe(env);
9774                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
9775         }
9776         if (get_jenv_res == JNI_EDETACHED) {
9777                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9778         }
9779 }
9780 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
9781         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
9782         JNIEnv *env;
9783         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9784         if (get_jenv_res == JNI_EDETACHED) {
9785                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9786         } else {
9787                 DO_ASSERT(get_jenv_res == JNI_OK);
9788         }
9789         LDKWatchedOutput output_var = output;
9790         int64_t output_ref = 0;
9791         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9792         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9793         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
9794         output_ref = (uintptr_t)output_var.inner;
9795         if (output_var.is_owned) {
9796                 output_ref |= 1;
9797         }
9798         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9799         CHECK(obj != NULL);
9800         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
9801         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9802                 (*env)->ExceptionDescribe(env);
9803                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
9804         }
9805         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9806         CHECK_ACCESS(ret_ptr);
9807         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
9808         FREE((void*)ret);
9809         if (get_jenv_res == JNI_EDETACHED) {
9810                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9811         }
9812         return ret_conv;
9813 }
9814 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
9815         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
9816         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9817 }
9818 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
9819         jclass c = (*env)->GetObjectClass(env, o);
9820         CHECK(c != NULL);
9821         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
9822         atomic_init(&calls->refcnt, 1);
9823         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9824         calls->o = (*env)->NewWeakGlobalRef(env, o);
9825         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
9826         CHECK(calls->register_tx_meth != NULL);
9827         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
9828         CHECK(calls->register_output_meth != NULL);
9829
9830         LDKFilter ret = {
9831                 .this_arg = (void*) calls,
9832                 .register_tx = register_tx_LDKFilter_jcall,
9833                 .register_output = register_output_LDKFilter_jcall,
9834                 .free = LDKFilter_JCalls_free,
9835         };
9836         return ret;
9837 }
9838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
9839         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
9840         *res_ptr = LDKFilter_init(env, clz, o);
9841         return (uint64_t)res_ptr;
9842 }
9843 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) {
9844         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9845         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9846         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9847         unsigned char txid_arr[32];
9848         CHECK((*env)->GetArrayLength(env, txid) == 32);
9849         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
9850         unsigned char (*txid_ref)[32] = &txid_arr;
9851         LDKu8slice script_pubkey_ref;
9852         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
9853         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
9854         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
9855         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
9856 }
9857
9858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
9859         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9860         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9861         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
9862         LDKWatchedOutput output_conv;
9863         output_conv.inner = (void*)(output & (~1));
9864         output_conv.is_owned = (output & 1) || (output == 0);
9865         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
9866         output_conv = WatchedOutput_clone(&output_conv);
9867         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9868         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
9869         int64_t ret_ref = (uintptr_t)ret_copy;
9870         return ret_ref;
9871 }
9872
9873 static jclass LDKCOption_FilterZ_Some_class = NULL;
9874 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
9875 static jclass LDKCOption_FilterZ_None_class = NULL;
9876 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
9877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
9878         LDKCOption_FilterZ_Some_class =
9879                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
9880         CHECK(LDKCOption_FilterZ_Some_class != NULL);
9881         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
9882         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
9883         LDKCOption_FilterZ_None_class =
9884                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
9885         CHECK(LDKCOption_FilterZ_None_class != NULL);
9886         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
9887         CHECK(LDKCOption_FilterZ_None_meth != NULL);
9888 }
9889 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9890         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
9891         switch(obj->tag) {
9892                 case LDKCOption_FilterZ_Some: {
9893                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
9894                         *some_ret = obj->some;
9895                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
9896                         if ((*some_ret).free == LDKFilter_JCalls_free) {
9897                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9898                                 LDKFilter_JCalls_cloned(&(*some_ret));
9899                         }
9900                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (int64_t)some_ret);
9901                 }
9902                 case LDKCOption_FilterZ_None: {
9903                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
9904                 }
9905                 default: abort();
9906         }
9907 }
9908 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9909 CHECK(owner->result_ok);
9910         return &*owner->contents.result;
9911 }
9912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9913         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9914         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
9915         int64_t ret_ref = 0;
9916         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9917         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9919         ret_ref = (uintptr_t)ret_var.inner & ~1;
9920         return ret_ref;
9921 }
9922
9923 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
9924 CHECK(!owner->result_ok);
9925         return *owner->contents.err;
9926 }
9927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9928         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
9929         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
9930 }
9931
9932 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
9933         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
9934         for (size_t i = 0; i < ret.datalen; i++) {
9935                 ret.data[i] = OutPoint_clone(&orig->data[i]);
9936         }
9937         return ret;
9938 }
9939 typedef struct LDKMessageSendEventsProvider_JCalls {
9940         atomic_size_t refcnt;
9941         JavaVM *vm;
9942         jweak o;
9943         jmethodID get_and_clear_pending_msg_events_meth;
9944 } LDKMessageSendEventsProvider_JCalls;
9945 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
9946         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9947         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9948                 JNIEnv *env;
9949                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9950                 if (get_jenv_res == JNI_EDETACHED) {
9951                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9952                 } else {
9953                         DO_ASSERT(get_jenv_res == JNI_OK);
9954                 }
9955                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9956                 if (get_jenv_res == JNI_EDETACHED) {
9957                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9958                 }
9959                 FREE(j_calls);
9960         }
9961 }
9962 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
9963         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
9964         JNIEnv *env;
9965         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9966         if (get_jenv_res == JNI_EDETACHED) {
9967                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9968         } else {
9969                 DO_ASSERT(get_jenv_res == JNI_OK);
9970         }
9971         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9972         CHECK(obj != NULL);
9973         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
9974         if (UNLIKELY((*env)->ExceptionCheck(env))) {
9975                 (*env)->ExceptionDescribe(env);
9976                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
9977         }
9978         LDKCVec_MessageSendEventZ ret_constr;
9979         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9980         if (ret_constr.datalen > 0)
9981                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
9982         else
9983                 ret_constr.data = NULL;
9984         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9985         for (size_t s = 0; s < ret_constr.datalen; s++) {
9986                 int64_t ret_conv_18 = ret_vals[s];
9987                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
9988                 CHECK_ACCESS(ret_conv_18_ptr);
9989                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
9990                 FREE((void*)ret_conv_18);
9991                 ret_constr.data[s] = ret_conv_18_conv;
9992         }
9993         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9994         if (get_jenv_res == JNI_EDETACHED) {
9995                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9996         }
9997         return ret_constr;
9998 }
9999 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10000         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10001         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10002 }
10003 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10004         jclass c = (*env)->GetObjectClass(env, o);
10005         CHECK(c != NULL);
10006         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10007         atomic_init(&calls->refcnt, 1);
10008         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10009         calls->o = (*env)->NewWeakGlobalRef(env, o);
10010         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10011         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10012
10013         LDKMessageSendEventsProvider ret = {
10014                 .this_arg = (void*) calls,
10015                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10016                 .free = LDKMessageSendEventsProvider_JCalls_free,
10017         };
10018         return ret;
10019 }
10020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10021         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10022         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10023         return (uint64_t)res_ptr;
10024 }
10025 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10026         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10027         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10028         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10029         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10030         int64_tArray ret_arr = NULL;
10031         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10032         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10033         for (size_t s = 0; s < ret_var.datalen; s++) {
10034                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10035                 *ret_conv_18_copy = ret_var.data[s];
10036                 int64_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
10037                 ret_arr_ptr[s] = ret_conv_18_ref;
10038         }
10039         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10040         FREE(ret_var.data);
10041         return ret_arr;
10042 }
10043
10044 typedef struct LDKEventHandler_JCalls {
10045         atomic_size_t refcnt;
10046         JavaVM *vm;
10047         jweak o;
10048         jmethodID handle_event_meth;
10049 } LDKEventHandler_JCalls;
10050 static void LDKEventHandler_JCalls_free(void* this_arg) {
10051         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10052         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10053                 JNIEnv *env;
10054                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10055                 if (get_jenv_res == JNI_EDETACHED) {
10056                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10057                 } else {
10058                         DO_ASSERT(get_jenv_res == JNI_OK);
10059                 }
10060                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10061                 if (get_jenv_res == JNI_EDETACHED) {
10062                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10063                 }
10064                 FREE(j_calls);
10065         }
10066 }
10067 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10068         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10069         JNIEnv *env;
10070         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10071         if (get_jenv_res == JNI_EDETACHED) {
10072                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10073         } else {
10074                 DO_ASSERT(get_jenv_res == JNI_OK);
10075         }
10076         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10077         *ret_event = Event_clone(event);
10078         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10079         CHECK(obj != NULL);
10080         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (int64_t)ret_event);
10081         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10082                 (*env)->ExceptionDescribe(env);
10083                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10084         }
10085         if (get_jenv_res == JNI_EDETACHED) {
10086                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10087         }
10088 }
10089 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10090         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10091         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10092 }
10093 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10094         jclass c = (*env)->GetObjectClass(env, o);
10095         CHECK(c != NULL);
10096         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10097         atomic_init(&calls->refcnt, 1);
10098         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10099         calls->o = (*env)->NewWeakGlobalRef(env, o);
10100         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10101         CHECK(calls->handle_event_meth != NULL);
10102
10103         LDKEventHandler ret = {
10104                 .this_arg = (void*) calls,
10105                 .handle_event = handle_event_LDKEventHandler_jcall,
10106                 .free = LDKEventHandler_JCalls_free,
10107         };
10108         return ret;
10109 }
10110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10111         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10112         *res_ptr = LDKEventHandler_init(env, clz, o);
10113         return (uint64_t)res_ptr;
10114 }
10115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10116         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10117         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10118         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10119         LDKEvent* event_conv = (LDKEvent*)event;
10120         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10121 }
10122
10123 typedef struct LDKEventsProvider_JCalls {
10124         atomic_size_t refcnt;
10125         JavaVM *vm;
10126         jweak o;
10127         jmethodID process_pending_events_meth;
10128 } LDKEventsProvider_JCalls;
10129 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10130         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10131         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10132                 JNIEnv *env;
10133                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10134                 if (get_jenv_res == JNI_EDETACHED) {
10135                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10136                 } else {
10137                         DO_ASSERT(get_jenv_res == JNI_OK);
10138                 }
10139                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10140                 if (get_jenv_res == JNI_EDETACHED) {
10141                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10142                 }
10143                 FREE(j_calls);
10144         }
10145 }
10146 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10147         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10148         JNIEnv *env;
10149         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10150         if (get_jenv_res == JNI_EDETACHED) {
10151                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10152         } else {
10153                 DO_ASSERT(get_jenv_res == JNI_OK);
10154         }
10155         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10156         *handler_ret = handler;
10157         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10158         CHECK(obj != NULL);
10159         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (int64_t)handler_ret);
10160         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10161                 (*env)->ExceptionDescribe(env);
10162                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10163         }
10164         if (get_jenv_res == JNI_EDETACHED) {
10165                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10166         }
10167 }
10168 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10169         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10170         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10171 }
10172 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10173         jclass c = (*env)->GetObjectClass(env, o);
10174         CHECK(c != NULL);
10175         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10176         atomic_init(&calls->refcnt, 1);
10177         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10178         calls->o = (*env)->NewWeakGlobalRef(env, o);
10179         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10180         CHECK(calls->process_pending_events_meth != NULL);
10181
10182         LDKEventsProvider ret = {
10183                 .this_arg = (void*) calls,
10184                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10185                 .free = LDKEventsProvider_JCalls_free,
10186         };
10187         return ret;
10188 }
10189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10190         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10191         *res_ptr = LDKEventsProvider_init(env, clz, o);
10192         return (uint64_t)res_ptr;
10193 }
10194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10195         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10196         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10197         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10198         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
10199         CHECK_ACCESS(handler_ptr);
10200         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10201         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10202                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10203                 LDKEventHandler_JCalls_cloned(&handler_conv);
10204         }
10205         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10206 }
10207
10208 typedef struct LDKListen_JCalls {
10209         atomic_size_t refcnt;
10210         JavaVM *vm;
10211         jweak o;
10212         jmethodID block_connected_meth;
10213         jmethodID block_disconnected_meth;
10214 } LDKListen_JCalls;
10215 static void LDKListen_JCalls_free(void* this_arg) {
10216         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10217         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10218                 JNIEnv *env;
10219                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10220                 if (get_jenv_res == JNI_EDETACHED) {
10221                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10222                 } else {
10223                         DO_ASSERT(get_jenv_res == JNI_OK);
10224                 }
10225                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10226                 if (get_jenv_res == JNI_EDETACHED) {
10227                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10228                 }
10229                 FREE(j_calls);
10230         }
10231 }
10232 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
10233         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10234         JNIEnv *env;
10235         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10236         if (get_jenv_res == JNI_EDETACHED) {
10237                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10238         } else {
10239                 DO_ASSERT(get_jenv_res == JNI_OK);
10240         }
10241         LDKu8slice block_var = block;
10242         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
10243         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
10244         int32_t height_conv = height;
10245         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10246         CHECK(obj != NULL);
10247         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
10248         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10249                 (*env)->ExceptionDescribe(env);
10250                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
10251         }
10252         if (get_jenv_res == JNI_EDETACHED) {
10253                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10254         }
10255 }
10256 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10257         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
10258         JNIEnv *env;
10259         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10260         if (get_jenv_res == JNI_EDETACHED) {
10261                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10262         } else {
10263                 DO_ASSERT(get_jenv_res == JNI_OK);
10264         }
10265         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10266         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10267         int32_t height_conv = height;
10268         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10269         CHECK(obj != NULL);
10270         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
10271         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10272                 (*env)->ExceptionDescribe(env);
10273                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
10274         }
10275         if (get_jenv_res == JNI_EDETACHED) {
10276                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10277         }
10278 }
10279 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
10280         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
10281         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10282 }
10283 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
10284         jclass c = (*env)->GetObjectClass(env, o);
10285         CHECK(c != NULL);
10286         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
10287         atomic_init(&calls->refcnt, 1);
10288         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10289         calls->o = (*env)->NewWeakGlobalRef(env, o);
10290         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
10291         CHECK(calls->block_connected_meth != NULL);
10292         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
10293         CHECK(calls->block_disconnected_meth != NULL);
10294
10295         LDKListen ret = {
10296                 .this_arg = (void*) calls,
10297                 .block_connected = block_connected_LDKListen_jcall,
10298                 .block_disconnected = block_disconnected_LDKListen_jcall,
10299                 .free = LDKListen_JCalls_free,
10300         };
10301         return ret;
10302 }
10303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
10304         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
10305         *res_ptr = LDKListen_init(env, clz, o);
10306         return (uint64_t)res_ptr;
10307 }
10308 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) {
10309         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10310         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10311         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10312         LDKu8slice block_ref;
10313         block_ref.datalen = (*env)->GetArrayLength(env, block);
10314         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
10315         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
10316         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
10317 }
10318
10319 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) {
10320         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10321         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10322         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
10323         unsigned char header_arr[80];
10324         CHECK((*env)->GetArrayLength(env, header) == 80);
10325         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10326         unsigned char (*header_ref)[80] = &header_arr;
10327         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
10328 }
10329
10330 typedef struct LDKConfirm_JCalls {
10331         atomic_size_t refcnt;
10332         JavaVM *vm;
10333         jweak o;
10334         jmethodID transactions_confirmed_meth;
10335         jmethodID transaction_unconfirmed_meth;
10336         jmethodID best_block_updated_meth;
10337         jmethodID get_relevant_txids_meth;
10338 } LDKConfirm_JCalls;
10339 static void LDKConfirm_JCalls_free(void* this_arg) {
10340         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10341         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
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                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10350                 if (get_jenv_res == JNI_EDETACHED) {
10351                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10352                 }
10353                 FREE(j_calls);
10354         }
10355 }
10356 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
10357         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10358         JNIEnv *env;
10359         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10360         if (get_jenv_res == JNI_EDETACHED) {
10361                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10362         } else {
10363                 DO_ASSERT(get_jenv_res == JNI_OK);
10364         }
10365         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10366         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10367         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
10368         int64_tArray txdata_arr = NULL;
10369         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
10370         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
10371         for (size_t c = 0; c < txdata_var.datalen; c++) {
10372                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10373                 *txdata_conv_28_conv = txdata_var.data[c];
10374                 txdata_arr_ptr[c] = ((int64_t)txdata_conv_28_conv);
10375         }
10376         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
10377         FREE(txdata_var.data);
10378         int32_t height_conv = height;
10379         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10380         CHECK(obj != NULL);
10381         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
10382         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10383                 (*env)->ExceptionDescribe(env);
10384                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
10385         }
10386         if (get_jenv_res == JNI_EDETACHED) {
10387                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10388         }
10389 }
10390 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
10391         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10392         JNIEnv *env;
10393         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10394         if (get_jenv_res == JNI_EDETACHED) {
10395                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10396         } else {
10397                 DO_ASSERT(get_jenv_res == JNI_OK);
10398         }
10399         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10400         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10401         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10402         CHECK(obj != NULL);
10403         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
10404         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10405                 (*env)->ExceptionDescribe(env);
10406                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
10407         }
10408         if (get_jenv_res == JNI_EDETACHED) {
10409                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10410         }
10411 }
10412 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
10413         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
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         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
10422         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
10423         int32_t height_conv = height;
10424         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10425         CHECK(obj != NULL);
10426         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
10427         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10428                 (*env)->ExceptionDescribe(env);
10429                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
10430         }
10431         if (get_jenv_res == JNI_EDETACHED) {
10432                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10433         }
10434 }
10435 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
10436         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
10437         JNIEnv *env;
10438         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10439         if (get_jenv_res == JNI_EDETACHED) {
10440                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10441         } else {
10442                 DO_ASSERT(get_jenv_res == JNI_OK);
10443         }
10444         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10445         CHECK(obj != NULL);
10446         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
10447         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10448                 (*env)->ExceptionDescribe(env);
10449                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
10450         }
10451         LDKCVec_TxidZ ret_constr;
10452         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10453         if (ret_constr.datalen > 0)
10454                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
10455         else
10456                 ret_constr.data = NULL;
10457         for (size_t i = 0; i < ret_constr.datalen; i++) {
10458                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
10459                 LDKThirtyTwoBytes ret_conv_8_ref;
10460                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
10461                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
10462                 ret_constr.data[i] = ret_conv_8_ref;
10463         }
10464         if (get_jenv_res == JNI_EDETACHED) {
10465                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10466         }
10467         return ret_constr;
10468 }
10469 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
10470         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
10471         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10472 }
10473 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
10474         jclass c = (*env)->GetObjectClass(env, o);
10475         CHECK(c != NULL);
10476         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
10477         atomic_init(&calls->refcnt, 1);
10478         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10479         calls->o = (*env)->NewWeakGlobalRef(env, o);
10480         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
10481         CHECK(calls->transactions_confirmed_meth != NULL);
10482         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
10483         CHECK(calls->transaction_unconfirmed_meth != NULL);
10484         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
10485         CHECK(calls->best_block_updated_meth != NULL);
10486         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
10487         CHECK(calls->get_relevant_txids_meth != NULL);
10488
10489         LDKConfirm ret = {
10490                 .this_arg = (void*) calls,
10491                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
10492                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
10493                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
10494                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
10495                 .free = LDKConfirm_JCalls_free,
10496         };
10497         return ret;
10498 }
10499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
10500         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
10501         *res_ptr = LDKConfirm_init(env, clz, o);
10502         return (uint64_t)res_ptr;
10503 }
10504 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) {
10505         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10506         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10507         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10508         unsigned char header_arr[80];
10509         CHECK((*env)->GetArrayLength(env, header) == 80);
10510         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10511         unsigned char (*header_ref)[80] = &header_arr;
10512         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
10513         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
10514         if (txdata_constr.datalen > 0)
10515                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10516         else
10517                 txdata_constr.data = NULL;
10518         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
10519         for (size_t c = 0; c < txdata_constr.datalen; c++) {
10520                 int64_t txdata_conv_28 = txdata_vals[c];
10521                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
10522                 CHECK_ACCESS(txdata_conv_28_ptr);
10523                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
10524                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
10525                 txdata_constr.data[c] = txdata_conv_28_conv;
10526         }
10527         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
10528         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
10529 }
10530
10531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
10532         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10533         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10534         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10535         unsigned char txid_arr[32];
10536         CHECK((*env)->GetArrayLength(env, txid) == 32);
10537         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10538         unsigned char (*txid_ref)[32] = &txid_arr;
10539         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
10540 }
10541
10542 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) {
10543         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10544         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10545         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10546         unsigned char header_arr[80];
10547         CHECK((*env)->GetArrayLength(env, header) == 80);
10548         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
10549         unsigned char (*header_ref)[80] = &header_arr;
10550         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
10551 }
10552
10553 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
10554         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10555         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10556         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
10557         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
10558         jobjectArray ret_arr = NULL;
10559         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
10560         ;
10561         for (size_t i = 0; i < ret_var.datalen; i++) {
10562                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
10563                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
10564                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
10565         }
10566         
10567         FREE(ret_var.data);
10568         return ret_arr;
10569 }
10570
10571 typedef struct LDKPersist_JCalls {
10572         atomic_size_t refcnt;
10573         JavaVM *vm;
10574         jweak o;
10575         jmethodID persist_new_channel_meth;
10576         jmethodID update_persisted_channel_meth;
10577 } LDKPersist_JCalls;
10578 static void LDKPersist_JCalls_free(void* this_arg) {
10579         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10580         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10581                 JNIEnv *env;
10582                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10583                 if (get_jenv_res == JNI_EDETACHED) {
10584                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10585                 } else {
10586                         DO_ASSERT(get_jenv_res == JNI_OK);
10587                 }
10588                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10589                 if (get_jenv_res == JNI_EDETACHED) {
10590                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10591                 }
10592                 FREE(j_calls);
10593         }
10594 }
10595 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10596         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10597         JNIEnv *env;
10598         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10599         if (get_jenv_res == JNI_EDETACHED) {
10600                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10601         } else {
10602                 DO_ASSERT(get_jenv_res == JNI_OK);
10603         }
10604         LDKOutPoint channel_id_var = channel_id;
10605         int64_t channel_id_ref = 0;
10606         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10607         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10608         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10609         channel_id_ref = (uintptr_t)channel_id_var.inner;
10610         if (channel_id_var.is_owned) {
10611                 channel_id_ref |= 1;
10612         }
10613         LDKChannelMonitor data_var = *data;
10614         int64_t data_ref = 0;
10615         data_var = ChannelMonitor_clone(&data_var);
10616         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10617         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10618         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10619         data_ref = (uintptr_t)data_var.inner;
10620         if (data_var.is_owned) {
10621                 data_ref |= 1;
10622         }
10623         LDKMonitorUpdateId update_id_var = update_id;
10624         int64_t update_id_ref = 0;
10625         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10626         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10627         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10628         update_id_ref = (uintptr_t)update_id_var.inner;
10629         if (update_id_var.is_owned) {
10630                 update_id_ref |= 1;
10631         }
10632         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10633         CHECK(obj != NULL);
10634         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
10635         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10636                 (*env)->ExceptionDescribe(env);
10637                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
10638         }
10639         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10640         CHECK_ACCESS(ret_ptr);
10641         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10642         FREE((void*)ret);
10643         if (get_jenv_res == JNI_EDETACHED) {
10644                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10645         }
10646         return ret_conv;
10647 }
10648 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
10649         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
10650         JNIEnv *env;
10651         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10652         if (get_jenv_res == JNI_EDETACHED) {
10653                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10654         } else {
10655                 DO_ASSERT(get_jenv_res == JNI_OK);
10656         }
10657         LDKOutPoint channel_id_var = channel_id;
10658         int64_t channel_id_ref = 0;
10659         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10660         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10661         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
10662         channel_id_ref = (uintptr_t)channel_id_var.inner;
10663         if (channel_id_var.is_owned) {
10664                 channel_id_ref |= 1;
10665         }
10666         LDKChannelMonitorUpdate update_var = *update;
10667         int64_t update_ref = 0;
10668         if ((uintptr_t)update_var.inner > 4096) {
10669                 update_var = ChannelMonitorUpdate_clone(&update_var);
10670                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10671                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10672         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
10673                 update_ref = (uintptr_t)update_var.inner;
10674                 if (update_var.is_owned) {
10675                         update_ref |= 1;
10676                 }
10677         }
10678         LDKChannelMonitor data_var = *data;
10679         int64_t data_ref = 0;
10680         data_var = ChannelMonitor_clone(&data_var);
10681         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10682         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10683         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
10684         data_ref = (uintptr_t)data_var.inner;
10685         if (data_var.is_owned) {
10686                 data_ref |= 1;
10687         }
10688         LDKMonitorUpdateId update_id_var = update_id;
10689         int64_t update_id_ref = 0;
10690         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10691         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10692         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
10693         update_id_ref = (uintptr_t)update_id_var.inner;
10694         if (update_id_var.is_owned) {
10695                 update_id_ref |= 1;
10696         }
10697         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10698         CHECK(obj != NULL);
10699         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
10700         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10701                 (*env)->ExceptionDescribe(env);
10702                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
10703         }
10704         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10705         CHECK_ACCESS(ret_ptr);
10706         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
10707         FREE((void*)ret);
10708         if (get_jenv_res == JNI_EDETACHED) {
10709                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10710         }
10711         return ret_conv;
10712 }
10713 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
10714         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
10715         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10716 }
10717 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
10718         jclass c = (*env)->GetObjectClass(env, o);
10719         CHECK(c != NULL);
10720         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
10721         atomic_init(&calls->refcnt, 1);
10722         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10723         calls->o = (*env)->NewWeakGlobalRef(env, o);
10724         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
10725         CHECK(calls->persist_new_channel_meth != NULL);
10726         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
10727         CHECK(calls->update_persisted_channel_meth != NULL);
10728
10729         LDKPersist ret = {
10730                 .this_arg = (void*) calls,
10731                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
10732                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
10733                 .free = LDKPersist_JCalls_free,
10734         };
10735         return ret;
10736 }
10737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
10738         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
10739         *res_ptr = LDKPersist_init(env, clz, o);
10740         return (uint64_t)res_ptr;
10741 }
10742 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) {
10743         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10744         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10745         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10746         LDKOutPoint channel_id_conv;
10747         channel_id_conv.inner = (void*)(channel_id & (~1));
10748         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
10749         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10750         channel_id_conv = OutPoint_clone(&channel_id_conv);
10751         LDKChannelMonitor data_conv;
10752         data_conv.inner = (void*)(data & (~1));
10753         data_conv.is_owned = false;
10754         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10755         LDKMonitorUpdateId update_id_conv;
10756         update_id_conv.inner = (void*)(update_id & (~1));
10757         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
10758         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10759         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10760         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10761         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
10762         return (int64_t)ret_conv;
10763 }
10764
10765 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) {
10766         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10767         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10768         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
10769         LDKOutPoint channel_id_conv;
10770         channel_id_conv.inner = (void*)(channel_id & (~1));
10771         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
10772         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
10773         channel_id_conv = OutPoint_clone(&channel_id_conv);
10774         LDKChannelMonitorUpdate update_conv;
10775         update_conv.inner = (void*)(update & (~1));
10776         update_conv.is_owned = false;
10777         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
10778         LDKChannelMonitor data_conv;
10779         data_conv.inner = (void*)(data & (~1));
10780         data_conv.is_owned = false;
10781         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
10782         LDKMonitorUpdateId update_id_conv;
10783         update_id_conv.inner = (void*)(update_id & (~1));
10784         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
10785         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
10786         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
10787         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
10788         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
10789         return (int64_t)ret_conv;
10790 }
10791
10792 typedef struct LDKChannelMessageHandler_JCalls {
10793         atomic_size_t refcnt;
10794         JavaVM *vm;
10795         jweak o;
10796         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
10797         jmethodID handle_open_channel_meth;
10798         jmethodID handle_accept_channel_meth;
10799         jmethodID handle_funding_created_meth;
10800         jmethodID handle_funding_signed_meth;
10801         jmethodID handle_funding_locked_meth;
10802         jmethodID handle_shutdown_meth;
10803         jmethodID handle_closing_signed_meth;
10804         jmethodID handle_update_add_htlc_meth;
10805         jmethodID handle_update_fulfill_htlc_meth;
10806         jmethodID handle_update_fail_htlc_meth;
10807         jmethodID handle_update_fail_malformed_htlc_meth;
10808         jmethodID handle_commitment_signed_meth;
10809         jmethodID handle_revoke_and_ack_meth;
10810         jmethodID handle_update_fee_meth;
10811         jmethodID handle_announcement_signatures_meth;
10812         jmethodID peer_disconnected_meth;
10813         jmethodID peer_connected_meth;
10814         jmethodID handle_channel_reestablish_meth;
10815         jmethodID handle_channel_update_meth;
10816         jmethodID handle_error_meth;
10817 } LDKChannelMessageHandler_JCalls;
10818 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
10819         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10820         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10821                 JNIEnv *env;
10822                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10823                 if (get_jenv_res == JNI_EDETACHED) {
10824                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10825                 } else {
10826                         DO_ASSERT(get_jenv_res == JNI_OK);
10827                 }
10828                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10829                 if (get_jenv_res == JNI_EDETACHED) {
10830                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10831                 }
10832                 FREE(j_calls);
10833         }
10834 }
10835 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
10836         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10837         JNIEnv *env;
10838         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10839         if (get_jenv_res == JNI_EDETACHED) {
10840                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10841         } else {
10842                 DO_ASSERT(get_jenv_res == JNI_OK);
10843         }
10844         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10845         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10846         LDKInitFeatures their_features_var = their_features;
10847         int64_t their_features_ref = 0;
10848         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10849         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10850         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10851         their_features_ref = (uintptr_t)their_features_var.inner;
10852         if (their_features_var.is_owned) {
10853                 their_features_ref |= 1;
10854         }
10855         LDKOpenChannel msg_var = *msg;
10856         int64_t msg_ref = 0;
10857         msg_var = OpenChannel_clone(&msg_var);
10858         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10859         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10860         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10861         msg_ref = (uintptr_t)msg_var.inner;
10862         if (msg_var.is_owned) {
10863                 msg_ref |= 1;
10864         }
10865         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10866         CHECK(obj != NULL);
10867         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10868         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10869                 (*env)->ExceptionDescribe(env);
10870                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
10871         }
10872         if (get_jenv_res == JNI_EDETACHED) {
10873                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10874         }
10875 }
10876 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
10877         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10878         JNIEnv *env;
10879         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10880         if (get_jenv_res == JNI_EDETACHED) {
10881                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10882         } else {
10883                 DO_ASSERT(get_jenv_res == JNI_OK);
10884         }
10885         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10886         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10887         LDKInitFeatures their_features_var = their_features;
10888         int64_t their_features_ref = 0;
10889         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10890         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10891         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
10892         their_features_ref = (uintptr_t)their_features_var.inner;
10893         if (their_features_var.is_owned) {
10894                 their_features_ref |= 1;
10895         }
10896         LDKAcceptChannel msg_var = *msg;
10897         int64_t msg_ref = 0;
10898         msg_var = AcceptChannel_clone(&msg_var);
10899         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10900         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10901         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10902         msg_ref = (uintptr_t)msg_var.inner;
10903         if (msg_var.is_owned) {
10904                 msg_ref |= 1;
10905         }
10906         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10907         CHECK(obj != NULL);
10908         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
10909         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10910                 (*env)->ExceptionDescribe(env);
10911                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
10912         }
10913         if (get_jenv_res == JNI_EDETACHED) {
10914                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10915         }
10916 }
10917 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
10918         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10919         JNIEnv *env;
10920         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10921         if (get_jenv_res == JNI_EDETACHED) {
10922                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10923         } else {
10924                 DO_ASSERT(get_jenv_res == JNI_OK);
10925         }
10926         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10927         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10928         LDKFundingCreated msg_var = *msg;
10929         int64_t msg_ref = 0;
10930         msg_var = FundingCreated_clone(&msg_var);
10931         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10932         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10933         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10934         msg_ref = (uintptr_t)msg_var.inner;
10935         if (msg_var.is_owned) {
10936                 msg_ref |= 1;
10937         }
10938         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10939         CHECK(obj != NULL);
10940         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
10941         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10942                 (*env)->ExceptionDescribe(env);
10943                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
10944         }
10945         if (get_jenv_res == JNI_EDETACHED) {
10946                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10947         }
10948 }
10949 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
10950         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10951         JNIEnv *env;
10952         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10953         if (get_jenv_res == JNI_EDETACHED) {
10954                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10955         } else {
10956                 DO_ASSERT(get_jenv_res == JNI_OK);
10957         }
10958         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10959         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10960         LDKFundingSigned msg_var = *msg;
10961         int64_t msg_ref = 0;
10962         msg_var = FundingSigned_clone(&msg_var);
10963         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10964         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10965         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10966         msg_ref = (uintptr_t)msg_var.inner;
10967         if (msg_var.is_owned) {
10968                 msg_ref |= 1;
10969         }
10970         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10971         CHECK(obj != NULL);
10972         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
10973         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10974                 (*env)->ExceptionDescribe(env);
10975                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
10976         }
10977         if (get_jenv_res == JNI_EDETACHED) {
10978                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10979         }
10980 }
10981 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
10982         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
10983         JNIEnv *env;
10984         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10985         if (get_jenv_res == JNI_EDETACHED) {
10986                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10987         } else {
10988                 DO_ASSERT(get_jenv_res == JNI_OK);
10989         }
10990         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
10991         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
10992         LDKFundingLocked msg_var = *msg;
10993         int64_t msg_ref = 0;
10994         msg_var = FundingLocked_clone(&msg_var);
10995         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10996         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10997         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
10998         msg_ref = (uintptr_t)msg_var.inner;
10999         if (msg_var.is_owned) {
11000                 msg_ref |= 1;
11001         }
11002         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11003         CHECK(obj != NULL);
11004         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
11005         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11006                 (*env)->ExceptionDescribe(env);
11007                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
11008         }
11009         if (get_jenv_res == JNI_EDETACHED) {
11010                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11011         }
11012 }
11013 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
11014         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11015         JNIEnv *env;
11016         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11017         if (get_jenv_res == JNI_EDETACHED) {
11018                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11019         } else {
11020                 DO_ASSERT(get_jenv_res == JNI_OK);
11021         }
11022         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11023         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11024         LDKInitFeatures their_features_var = *their_features;
11025         int64_t their_features_ref = 0;
11026         their_features_var = InitFeatures_clone(&their_features_var);
11027         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11028         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11029         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11030         their_features_ref = (uintptr_t)their_features_var.inner;
11031         if (their_features_var.is_owned) {
11032                 their_features_ref |= 1;
11033         }
11034         LDKShutdown msg_var = *msg;
11035         int64_t msg_ref = 0;
11036         msg_var = Shutdown_clone(&msg_var);
11037         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11038         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11039         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11040         msg_ref = (uintptr_t)msg_var.inner;
11041         if (msg_var.is_owned) {
11042                 msg_ref |= 1;
11043         }
11044         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11045         CHECK(obj != NULL);
11046         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
11047         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11048                 (*env)->ExceptionDescribe(env);
11049                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
11050         }
11051         if (get_jenv_res == JNI_EDETACHED) {
11052                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11053         }
11054 }
11055 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
11056         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11057         JNIEnv *env;
11058         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11059         if (get_jenv_res == JNI_EDETACHED) {
11060                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11061         } else {
11062                 DO_ASSERT(get_jenv_res == JNI_OK);
11063         }
11064         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11065         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11066         LDKClosingSigned msg_var = *msg;
11067         int64_t msg_ref = 0;
11068         msg_var = ClosingSigned_clone(&msg_var);
11069         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11070         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11071         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11072         msg_ref = (uintptr_t)msg_var.inner;
11073         if (msg_var.is_owned) {
11074                 msg_ref |= 1;
11075         }
11076         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11077         CHECK(obj != NULL);
11078         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
11079         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11080                 (*env)->ExceptionDescribe(env);
11081                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
11082         }
11083         if (get_jenv_res == JNI_EDETACHED) {
11084                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11085         }
11086 }
11087 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
11088         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11089         JNIEnv *env;
11090         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11091         if (get_jenv_res == JNI_EDETACHED) {
11092                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11093         } else {
11094                 DO_ASSERT(get_jenv_res == JNI_OK);
11095         }
11096         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11097         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11098         LDKUpdateAddHTLC msg_var = *msg;
11099         int64_t msg_ref = 0;
11100         msg_var = UpdateAddHTLC_clone(&msg_var);
11101         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11102         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11103         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11104         msg_ref = (uintptr_t)msg_var.inner;
11105         if (msg_var.is_owned) {
11106                 msg_ref |= 1;
11107         }
11108         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11109         CHECK(obj != NULL);
11110         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
11111         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11112                 (*env)->ExceptionDescribe(env);
11113                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
11114         }
11115         if (get_jenv_res == JNI_EDETACHED) {
11116                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11117         }
11118 }
11119 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
11120         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11121         JNIEnv *env;
11122         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11123         if (get_jenv_res == JNI_EDETACHED) {
11124                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11125         } else {
11126                 DO_ASSERT(get_jenv_res == JNI_OK);
11127         }
11128         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11129         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11130         LDKUpdateFulfillHTLC msg_var = *msg;
11131         int64_t msg_ref = 0;
11132         msg_var = UpdateFulfillHTLC_clone(&msg_var);
11133         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11134         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11135         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11136         msg_ref = (uintptr_t)msg_var.inner;
11137         if (msg_var.is_owned) {
11138                 msg_ref |= 1;
11139         }
11140         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11141         CHECK(obj != NULL);
11142         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
11143         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11144                 (*env)->ExceptionDescribe(env);
11145                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
11146         }
11147         if (get_jenv_res == JNI_EDETACHED) {
11148                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11149         }
11150 }
11151 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
11152         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11153         JNIEnv *env;
11154         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11155         if (get_jenv_res == JNI_EDETACHED) {
11156                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11157         } else {
11158                 DO_ASSERT(get_jenv_res == JNI_OK);
11159         }
11160         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11161         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11162         LDKUpdateFailHTLC msg_var = *msg;
11163         int64_t msg_ref = 0;
11164         msg_var = UpdateFailHTLC_clone(&msg_var);
11165         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11166         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11167         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11168         msg_ref = (uintptr_t)msg_var.inner;
11169         if (msg_var.is_owned) {
11170                 msg_ref |= 1;
11171         }
11172         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11173         CHECK(obj != NULL);
11174         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
11175         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11176                 (*env)->ExceptionDescribe(env);
11177                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
11178         }
11179         if (get_jenv_res == JNI_EDETACHED) {
11180                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11181         }
11182 }
11183 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
11184         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11185         JNIEnv *env;
11186         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11187         if (get_jenv_res == JNI_EDETACHED) {
11188                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11189         } else {
11190                 DO_ASSERT(get_jenv_res == JNI_OK);
11191         }
11192         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11193         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11194         LDKUpdateFailMalformedHTLC msg_var = *msg;
11195         int64_t msg_ref = 0;
11196         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
11197         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11198         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11199         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11200         msg_ref = (uintptr_t)msg_var.inner;
11201         if (msg_var.is_owned) {
11202                 msg_ref |= 1;
11203         }
11204         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11205         CHECK(obj != NULL);
11206         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
11207         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11208                 (*env)->ExceptionDescribe(env);
11209                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
11210         }
11211         if (get_jenv_res == JNI_EDETACHED) {
11212                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11213         }
11214 }
11215 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
11216         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11217         JNIEnv *env;
11218         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11219         if (get_jenv_res == JNI_EDETACHED) {
11220                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11221         } else {
11222                 DO_ASSERT(get_jenv_res == JNI_OK);
11223         }
11224         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11225         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11226         LDKCommitmentSigned msg_var = *msg;
11227         int64_t msg_ref = 0;
11228         msg_var = CommitmentSigned_clone(&msg_var);
11229         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11230         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11231         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11232         msg_ref = (uintptr_t)msg_var.inner;
11233         if (msg_var.is_owned) {
11234                 msg_ref |= 1;
11235         }
11236         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11237         CHECK(obj != NULL);
11238         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
11239         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11240                 (*env)->ExceptionDescribe(env);
11241                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
11242         }
11243         if (get_jenv_res == JNI_EDETACHED) {
11244                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11245         }
11246 }
11247 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
11248         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11249         JNIEnv *env;
11250         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11251         if (get_jenv_res == JNI_EDETACHED) {
11252                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11253         } else {
11254                 DO_ASSERT(get_jenv_res == JNI_OK);
11255         }
11256         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11257         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11258         LDKRevokeAndACK msg_var = *msg;
11259         int64_t msg_ref = 0;
11260         msg_var = RevokeAndACK_clone(&msg_var);
11261         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11262         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11263         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11264         msg_ref = (uintptr_t)msg_var.inner;
11265         if (msg_var.is_owned) {
11266                 msg_ref |= 1;
11267         }
11268         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11269         CHECK(obj != NULL);
11270         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
11271         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11272                 (*env)->ExceptionDescribe(env);
11273                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
11274         }
11275         if (get_jenv_res == JNI_EDETACHED) {
11276                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11277         }
11278 }
11279 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
11280         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11281         JNIEnv *env;
11282         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11283         if (get_jenv_res == JNI_EDETACHED) {
11284                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11285         } else {
11286                 DO_ASSERT(get_jenv_res == JNI_OK);
11287         }
11288         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11289         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11290         LDKUpdateFee msg_var = *msg;
11291         int64_t msg_ref = 0;
11292         msg_var = UpdateFee_clone(&msg_var);
11293         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11294         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11295         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11296         msg_ref = (uintptr_t)msg_var.inner;
11297         if (msg_var.is_owned) {
11298                 msg_ref |= 1;
11299         }
11300         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11301         CHECK(obj != NULL);
11302         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
11303         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11304                 (*env)->ExceptionDescribe(env);
11305                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
11306         }
11307         if (get_jenv_res == JNI_EDETACHED) {
11308                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11309         }
11310 }
11311 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
11312         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11313         JNIEnv *env;
11314         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11315         if (get_jenv_res == JNI_EDETACHED) {
11316                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11317         } else {
11318                 DO_ASSERT(get_jenv_res == JNI_OK);
11319         }
11320         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11321         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11322         LDKAnnouncementSignatures msg_var = *msg;
11323         int64_t msg_ref = 0;
11324         msg_var = AnnouncementSignatures_clone(&msg_var);
11325         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11326         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11327         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11328         msg_ref = (uintptr_t)msg_var.inner;
11329         if (msg_var.is_owned) {
11330                 msg_ref |= 1;
11331         }
11332         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11333         CHECK(obj != NULL);
11334         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
11335         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11336                 (*env)->ExceptionDescribe(env);
11337                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
11338         }
11339         if (get_jenv_res == JNI_EDETACHED) {
11340                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11341         }
11342 }
11343 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
11344         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11345         JNIEnv *env;
11346         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11347         if (get_jenv_res == JNI_EDETACHED) {
11348                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11349         } else {
11350                 DO_ASSERT(get_jenv_res == JNI_OK);
11351         }
11352         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11353         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11354         jboolean no_connection_possible_conv = no_connection_possible;
11355         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11356         CHECK(obj != NULL);
11357         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
11358         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11359                 (*env)->ExceptionDescribe(env);
11360                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
11361         }
11362         if (get_jenv_res == JNI_EDETACHED) {
11363                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11364         }
11365 }
11366 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
11367         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11368         JNIEnv *env;
11369         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11370         if (get_jenv_res == JNI_EDETACHED) {
11371                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11372         } else {
11373                 DO_ASSERT(get_jenv_res == JNI_OK);
11374         }
11375         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11376         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11377         LDKInit msg_var = *msg;
11378         int64_t msg_ref = 0;
11379         msg_var = Init_clone(&msg_var);
11380         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11381         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11382         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11383         msg_ref = (uintptr_t)msg_var.inner;
11384         if (msg_var.is_owned) {
11385                 msg_ref |= 1;
11386         }
11387         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11388         CHECK(obj != NULL);
11389         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
11390         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11391                 (*env)->ExceptionDescribe(env);
11392                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
11393         }
11394         if (get_jenv_res == JNI_EDETACHED) {
11395                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11396         }
11397 }
11398 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
11399         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11400         JNIEnv *env;
11401         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11402         if (get_jenv_res == JNI_EDETACHED) {
11403                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11404         } else {
11405                 DO_ASSERT(get_jenv_res == JNI_OK);
11406         }
11407         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11408         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11409         LDKChannelReestablish msg_var = *msg;
11410         int64_t msg_ref = 0;
11411         msg_var = ChannelReestablish_clone(&msg_var);
11412         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11413         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11414         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11415         msg_ref = (uintptr_t)msg_var.inner;
11416         if (msg_var.is_owned) {
11417                 msg_ref |= 1;
11418         }
11419         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11420         CHECK(obj != NULL);
11421         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
11422         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11423                 (*env)->ExceptionDescribe(env);
11424                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
11425         }
11426         if (get_jenv_res == JNI_EDETACHED) {
11427                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11428         }
11429 }
11430 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
11431         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11432         JNIEnv *env;
11433         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11434         if (get_jenv_res == JNI_EDETACHED) {
11435                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11436         } else {
11437                 DO_ASSERT(get_jenv_res == JNI_OK);
11438         }
11439         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11440         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11441         LDKChannelUpdate msg_var = *msg;
11442         int64_t msg_ref = 0;
11443         msg_var = ChannelUpdate_clone(&msg_var);
11444         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11445         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11446         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11447         msg_ref = (uintptr_t)msg_var.inner;
11448         if (msg_var.is_owned) {
11449                 msg_ref |= 1;
11450         }
11451         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11452         CHECK(obj != NULL);
11453         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
11454         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11455                 (*env)->ExceptionDescribe(env);
11456                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
11457         }
11458         if (get_jenv_res == JNI_EDETACHED) {
11459                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11460         }
11461 }
11462 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
11463         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11464         JNIEnv *env;
11465         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11466         if (get_jenv_res == JNI_EDETACHED) {
11467                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11468         } else {
11469                 DO_ASSERT(get_jenv_res == JNI_OK);
11470         }
11471         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11472         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11473         LDKErrorMessage msg_var = *msg;
11474         int64_t msg_ref = 0;
11475         msg_var = ErrorMessage_clone(&msg_var);
11476         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11477         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11478         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11479         msg_ref = (uintptr_t)msg_var.inner;
11480         if (msg_var.is_owned) {
11481                 msg_ref |= 1;
11482         }
11483         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11484         CHECK(obj != NULL);
11485         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
11486         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11487                 (*env)->ExceptionDescribe(env);
11488                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
11489         }
11490         if (get_jenv_res == JNI_EDETACHED) {
11491                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11492         }
11493 }
11494 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
11495         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
11496         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11497         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
11498 }
11499 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11500         jclass c = (*env)->GetObjectClass(env, o);
11501         CHECK(c != NULL);
11502         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
11503         atomic_init(&calls->refcnt, 1);
11504         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11505         calls->o = (*env)->NewWeakGlobalRef(env, o);
11506         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
11507         CHECK(calls->handle_open_channel_meth != NULL);
11508         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
11509         CHECK(calls->handle_accept_channel_meth != NULL);
11510         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
11511         CHECK(calls->handle_funding_created_meth != NULL);
11512         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
11513         CHECK(calls->handle_funding_signed_meth != NULL);
11514         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
11515         CHECK(calls->handle_funding_locked_meth != NULL);
11516         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
11517         CHECK(calls->handle_shutdown_meth != NULL);
11518         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
11519         CHECK(calls->handle_closing_signed_meth != NULL);
11520         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
11521         CHECK(calls->handle_update_add_htlc_meth != NULL);
11522         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
11523         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
11524         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
11525         CHECK(calls->handle_update_fail_htlc_meth != NULL);
11526         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
11527         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
11528         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
11529         CHECK(calls->handle_commitment_signed_meth != NULL);
11530         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
11531         CHECK(calls->handle_revoke_and_ack_meth != NULL);
11532         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
11533         CHECK(calls->handle_update_fee_meth != NULL);
11534         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
11535         CHECK(calls->handle_announcement_signatures_meth != NULL);
11536         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
11537         CHECK(calls->peer_disconnected_meth != NULL);
11538         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
11539         CHECK(calls->peer_connected_meth != NULL);
11540         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
11541         CHECK(calls->handle_channel_reestablish_meth != NULL);
11542         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
11543         CHECK(calls->handle_channel_update_meth != NULL);
11544         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
11545         CHECK(calls->handle_error_meth != NULL);
11546
11547         LDKChannelMessageHandler ret = {
11548                 .this_arg = (void*) calls,
11549                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
11550                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
11551                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
11552                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
11553                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
11554                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
11555                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
11556                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
11557                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
11558                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
11559                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
11560                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
11561                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
11562                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
11563                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
11564                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
11565                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
11566                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
11567                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
11568                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
11569                 .free = LDKChannelMessageHandler_JCalls_free,
11570                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
11571         };
11572         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
11573         return ret;
11574 }
11575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
11576         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
11577         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
11578         return (uint64_t)res_ptr;
11579 }
11580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
11581         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
11582         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
11583         DO_ASSERT((res_ptr & 1) == 0);
11584         return (int64_t)(res_ptr | 1);
11585 }
11586 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) {
11587         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11588         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11589         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11590         LDKPublicKey their_node_id_ref;
11591         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11592         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11593         LDKInitFeatures their_features_conv;
11594         their_features_conv.inner = (void*)(their_features & (~1));
11595         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
11596         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11597         their_features_conv = InitFeatures_clone(&their_features_conv);
11598         LDKOpenChannel msg_conv;
11599         msg_conv.inner = (void*)(msg & (~1));
11600         msg_conv.is_owned = false;
11601         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11602         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11603 }
11604
11605 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) {
11606         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11607         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11608         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11609         LDKPublicKey their_node_id_ref;
11610         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11611         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11612         LDKInitFeatures their_features_conv;
11613         their_features_conv.inner = (void*)(their_features & (~1));
11614         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
11615         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11616         their_features_conv = InitFeatures_clone(&their_features_conv);
11617         LDKAcceptChannel msg_conv;
11618         msg_conv.inner = (void*)(msg & (~1));
11619         msg_conv.is_owned = false;
11620         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11621         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
11622 }
11623
11624 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) {
11625         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11626         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11627         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11628         LDKPublicKey their_node_id_ref;
11629         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11630         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11631         LDKFundingCreated msg_conv;
11632         msg_conv.inner = (void*)(msg & (~1));
11633         msg_conv.is_owned = false;
11634         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11635         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11636 }
11637
11638 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) {
11639         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11640         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11641         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11642         LDKPublicKey their_node_id_ref;
11643         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11644         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11645         LDKFundingSigned msg_conv;
11646         msg_conv.inner = (void*)(msg & (~1));
11647         msg_conv.is_owned = false;
11648         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11649         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11650 }
11651
11652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
11653         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11654         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11655         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11656         LDKPublicKey their_node_id_ref;
11657         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11658         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11659         LDKFundingLocked msg_conv;
11660         msg_conv.inner = (void*)(msg & (~1));
11661         msg_conv.is_owned = false;
11662         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11663         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11664 }
11665
11666 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) {
11667         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11668         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11669         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11670         LDKPublicKey their_node_id_ref;
11671         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11672         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11673         LDKInitFeatures their_features_conv;
11674         their_features_conv.inner = (void*)(their_features & (~1));
11675         their_features_conv.is_owned = false;
11676         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
11677         LDKShutdown msg_conv;
11678         msg_conv.inner = (void*)(msg & (~1));
11679         msg_conv.is_owned = false;
11680         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11681         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
11682 }
11683
11684 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) {
11685         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11686         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11687         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11688         LDKPublicKey their_node_id_ref;
11689         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11690         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11691         LDKClosingSigned msg_conv;
11692         msg_conv.inner = (void*)(msg & (~1));
11693         msg_conv.is_owned = false;
11694         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11695         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11696 }
11697
11698 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) {
11699         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11700         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11701         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11702         LDKPublicKey their_node_id_ref;
11703         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11704         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11705         LDKUpdateAddHTLC msg_conv;
11706         msg_conv.inner = (void*)(msg & (~1));
11707         msg_conv.is_owned = false;
11708         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11709         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11710 }
11711
11712 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) {
11713         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11714         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11715         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11716         LDKPublicKey their_node_id_ref;
11717         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11718         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11719         LDKUpdateFulfillHTLC msg_conv;
11720         msg_conv.inner = (void*)(msg & (~1));
11721         msg_conv.is_owned = false;
11722         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11723         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11724 }
11725
11726 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) {
11727         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11728         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11729         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11730         LDKPublicKey their_node_id_ref;
11731         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11732         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11733         LDKUpdateFailHTLC msg_conv;
11734         msg_conv.inner = (void*)(msg & (~1));
11735         msg_conv.is_owned = false;
11736         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11737         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11738 }
11739
11740 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) {
11741         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11742         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11743         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11744         LDKPublicKey their_node_id_ref;
11745         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11746         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11747         LDKUpdateFailMalformedHTLC msg_conv;
11748         msg_conv.inner = (void*)(msg & (~1));
11749         msg_conv.is_owned = false;
11750         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11751         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11752 }
11753
11754 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) {
11755         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11756         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11757         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11758         LDKPublicKey their_node_id_ref;
11759         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11760         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11761         LDKCommitmentSigned msg_conv;
11762         msg_conv.inner = (void*)(msg & (~1));
11763         msg_conv.is_owned = false;
11764         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11765         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11766 }
11767
11768 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) {
11769         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11770         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11771         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11772         LDKPublicKey their_node_id_ref;
11773         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11774         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11775         LDKRevokeAndACK msg_conv;
11776         msg_conv.inner = (void*)(msg & (~1));
11777         msg_conv.is_owned = false;
11778         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11779         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11780 }
11781
11782 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) {
11783         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11784         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11785         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11786         LDKPublicKey their_node_id_ref;
11787         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11788         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11789         LDKUpdateFee msg_conv;
11790         msg_conv.inner = (void*)(msg & (~1));
11791         msg_conv.is_owned = false;
11792         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11793         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11794 }
11795
11796 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) {
11797         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11798         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11799         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11800         LDKPublicKey their_node_id_ref;
11801         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11802         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11803         LDKAnnouncementSignatures msg_conv;
11804         msg_conv.inner = (void*)(msg & (~1));
11805         msg_conv.is_owned = false;
11806         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11807         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11808 }
11809
11810 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) {
11811         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11812         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11813         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11814         LDKPublicKey their_node_id_ref;
11815         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11816         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11817         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
11818 }
11819
11820 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) {
11821         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11822         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11823         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11824         LDKPublicKey their_node_id_ref;
11825         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11826         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11827         LDKInit msg_conv;
11828         msg_conv.inner = (void*)(msg & (~1));
11829         msg_conv.is_owned = false;
11830         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11831         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11832 }
11833
11834 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) {
11835         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11836         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11837         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11838         LDKPublicKey their_node_id_ref;
11839         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11840         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11841         LDKChannelReestablish msg_conv;
11842         msg_conv.inner = (void*)(msg & (~1));
11843         msg_conv.is_owned = false;
11844         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11845         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11846 }
11847
11848 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) {
11849         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11850         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11851         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11852         LDKPublicKey their_node_id_ref;
11853         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11854         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11855         LDKChannelUpdate msg_conv;
11856         msg_conv.inner = (void*)(msg & (~1));
11857         msg_conv.is_owned = false;
11858         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11859         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11860 }
11861
11862 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) {
11863         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
11864         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
11865         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
11866         LDKPublicKey their_node_id_ref;
11867         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
11868         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
11869         LDKErrorMessage msg_conv;
11870         msg_conv.inner = (void*)(msg & (~1));
11871         msg_conv.is_owned = false;
11872         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
11873         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
11874 }
11875
11876 typedef struct LDKRoutingMessageHandler_JCalls {
11877         atomic_size_t refcnt;
11878         JavaVM *vm;
11879         jweak o;
11880         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11881         jmethodID handle_node_announcement_meth;
11882         jmethodID handle_channel_announcement_meth;
11883         jmethodID handle_channel_update_meth;
11884         jmethodID get_next_channel_announcements_meth;
11885         jmethodID get_next_node_announcements_meth;
11886         jmethodID peer_connected_meth;
11887         jmethodID handle_reply_channel_range_meth;
11888         jmethodID handle_reply_short_channel_ids_end_meth;
11889         jmethodID handle_query_channel_range_meth;
11890         jmethodID handle_query_short_channel_ids_meth;
11891 } LDKRoutingMessageHandler_JCalls;
11892 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
11893         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11894         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11895                 JNIEnv *env;
11896                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11897                 if (get_jenv_res == JNI_EDETACHED) {
11898                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11899                 } else {
11900                         DO_ASSERT(get_jenv_res == JNI_OK);
11901                 }
11902                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11903                 if (get_jenv_res == JNI_EDETACHED) {
11904                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11905                 }
11906                 FREE(j_calls);
11907         }
11908 }
11909 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
11910         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11911         JNIEnv *env;
11912         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11913         if (get_jenv_res == JNI_EDETACHED) {
11914                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11915         } else {
11916                 DO_ASSERT(get_jenv_res == JNI_OK);
11917         }
11918         LDKNodeAnnouncement msg_var = *msg;
11919         int64_t msg_ref = 0;
11920         msg_var = NodeAnnouncement_clone(&msg_var);
11921         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11922         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11923         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11924         msg_ref = (uintptr_t)msg_var.inner;
11925         if (msg_var.is_owned) {
11926                 msg_ref |= 1;
11927         }
11928         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11929         CHECK(obj != NULL);
11930         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
11931         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11932                 (*env)->ExceptionDescribe(env);
11933                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11934         }
11935         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11936         CHECK_ACCESS(ret_ptr);
11937         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11938         FREE((void*)ret);
11939         if (get_jenv_res == JNI_EDETACHED) {
11940                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11941         }
11942         return ret_conv;
11943 }
11944 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
11945         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11946         JNIEnv *env;
11947         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11948         if (get_jenv_res == JNI_EDETACHED) {
11949                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11950         } else {
11951                 DO_ASSERT(get_jenv_res == JNI_OK);
11952         }
11953         LDKChannelAnnouncement msg_var = *msg;
11954         int64_t msg_ref = 0;
11955         msg_var = ChannelAnnouncement_clone(&msg_var);
11956         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11957         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11958         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11959         msg_ref = (uintptr_t)msg_var.inner;
11960         if (msg_var.is_owned) {
11961                 msg_ref |= 1;
11962         }
11963         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11964         CHECK(obj != NULL);
11965         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
11966         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11967                 (*env)->ExceptionDescribe(env);
11968                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
11969         }
11970         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
11971         CHECK_ACCESS(ret_ptr);
11972         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
11973         FREE((void*)ret);
11974         if (get_jenv_res == JNI_EDETACHED) {
11975                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11976         }
11977         return ret_conv;
11978 }
11979 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
11980         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
11981         JNIEnv *env;
11982         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11983         if (get_jenv_res == JNI_EDETACHED) {
11984                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11985         } else {
11986                 DO_ASSERT(get_jenv_res == JNI_OK);
11987         }
11988         LDKChannelUpdate msg_var = *msg;
11989         int64_t msg_ref = 0;
11990         msg_var = ChannelUpdate_clone(&msg_var);
11991         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11992         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11993         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11994         msg_ref = (uintptr_t)msg_var.inner;
11995         if (msg_var.is_owned) {
11996                 msg_ref |= 1;
11997         }
11998         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11999         CHECK(obj != NULL);
12000         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
12001         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12002                 (*env)->ExceptionDescribe(env);
12003                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
12004         }
12005         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12006         CHECK_ACCESS(ret_ptr);
12007         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12008         FREE((void*)ret);
12009         if (get_jenv_res == JNI_EDETACHED) {
12010                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12011         }
12012         return ret_conv;
12013 }
12014 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
12015         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12016         JNIEnv *env;
12017         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12018         if (get_jenv_res == JNI_EDETACHED) {
12019                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12020         } else {
12021                 DO_ASSERT(get_jenv_res == JNI_OK);
12022         }
12023         int64_t starting_point_conv = starting_point;
12024         int8_t batch_amount_conv = batch_amount;
12025         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12026         CHECK(obj != NULL);
12027         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point_conv, batch_amount_conv);
12028         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12029                 (*env)->ExceptionDescribe(env);
12030                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
12031         }
12032         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
12033         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12034         if (ret_constr.datalen > 0)
12035                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
12036         else
12037                 ret_constr.data = NULL;
12038         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12039         for (size_t h = 0; h < ret_constr.datalen; h++) {
12040                 int64_t ret_conv_59 = ret_vals[h];
12041                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
12042                 CHECK_ACCESS(ret_conv_59_ptr);
12043                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
12044                 FREE((void*)ret_conv_59);
12045                 ret_constr.data[h] = ret_conv_59_conv;
12046         }
12047         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12048         if (get_jenv_res == JNI_EDETACHED) {
12049                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12050         }
12051         return ret_constr;
12052 }
12053 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
12054         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12055         JNIEnv *env;
12056         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12057         if (get_jenv_res == JNI_EDETACHED) {
12058                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12059         } else {
12060                 DO_ASSERT(get_jenv_res == JNI_OK);
12061         }
12062         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
12063         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
12064         int8_t batch_amount_conv = batch_amount;
12065         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12066         CHECK(obj != NULL);
12067         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount_conv);
12068         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12069                 (*env)->ExceptionDescribe(env);
12070                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
12071         }
12072         LDKCVec_NodeAnnouncementZ ret_constr;
12073         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12074         if (ret_constr.datalen > 0)
12075                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
12076         else
12077                 ret_constr.data = NULL;
12078         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12079         for (size_t s = 0; s < ret_constr.datalen; s++) {
12080                 int64_t ret_conv_18 = ret_vals[s];
12081                 LDKNodeAnnouncement ret_conv_18_conv;
12082                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
12083                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
12084                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
12085                 ret_constr.data[s] = ret_conv_18_conv;
12086         }
12087         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12088         if (get_jenv_res == JNI_EDETACHED) {
12089                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12090         }
12091         return ret_constr;
12092 }
12093 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
12094         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12095         JNIEnv *env;
12096         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12097         if (get_jenv_res == JNI_EDETACHED) {
12098                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12099         } else {
12100                 DO_ASSERT(get_jenv_res == JNI_OK);
12101         }
12102         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12103         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12104         LDKInit init_var = *init;
12105         int64_t init_ref = 0;
12106         init_var = Init_clone(&init_var);
12107         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12108         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12109         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
12110         init_ref = (uintptr_t)init_var.inner;
12111         if (init_var.is_owned) {
12112                 init_ref |= 1;
12113         }
12114         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12115         CHECK(obj != NULL);
12116         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
12117         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12118                 (*env)->ExceptionDescribe(env);
12119                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
12120         }
12121         if (get_jenv_res == JNI_EDETACHED) {
12122                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12123         }
12124 }
12125 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
12126         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12127         JNIEnv *env;
12128         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12129         if (get_jenv_res == JNI_EDETACHED) {
12130                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12131         } else {
12132                 DO_ASSERT(get_jenv_res == JNI_OK);
12133         }
12134         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12135         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12136         LDKReplyChannelRange msg_var = msg;
12137         int64_t msg_ref = 0;
12138         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12139         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12140         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12141         msg_ref = (uintptr_t)msg_var.inner;
12142         if (msg_var.is_owned) {
12143                 msg_ref |= 1;
12144         }
12145         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12146         CHECK(obj != NULL);
12147         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
12148         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12149                 (*env)->ExceptionDescribe(env);
12150                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12151         }
12152         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12153         CHECK_ACCESS(ret_ptr);
12154         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12155         FREE((void*)ret);
12156         if (get_jenv_res == JNI_EDETACHED) {
12157                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12158         }
12159         return ret_conv;
12160 }
12161 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
12162         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12163         JNIEnv *env;
12164         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12165         if (get_jenv_res == JNI_EDETACHED) {
12166                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12167         } else {
12168                 DO_ASSERT(get_jenv_res == JNI_OK);
12169         }
12170         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12171         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12172         LDKReplyShortChannelIdsEnd msg_var = msg;
12173         int64_t msg_ref = 0;
12174         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12175         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12176         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12177         msg_ref = (uintptr_t)msg_var.inner;
12178         if (msg_var.is_owned) {
12179                 msg_ref |= 1;
12180         }
12181         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12182         CHECK(obj != NULL);
12183         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
12184         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12185                 (*env)->ExceptionDescribe(env);
12186                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
12187         }
12188         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12189         CHECK_ACCESS(ret_ptr);
12190         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12191         FREE((void*)ret);
12192         if (get_jenv_res == JNI_EDETACHED) {
12193                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12194         }
12195         return ret_conv;
12196 }
12197 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
12198         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12199         JNIEnv *env;
12200         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12201         if (get_jenv_res == JNI_EDETACHED) {
12202                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12203         } else {
12204                 DO_ASSERT(get_jenv_res == JNI_OK);
12205         }
12206         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12207         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12208         LDKQueryChannelRange msg_var = msg;
12209         int64_t msg_ref = 0;
12210         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12211         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12212         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12213         msg_ref = (uintptr_t)msg_var.inner;
12214         if (msg_var.is_owned) {
12215                 msg_ref |= 1;
12216         }
12217         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12218         CHECK(obj != NULL);
12219         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
12220         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12221                 (*env)->ExceptionDescribe(env);
12222                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12223         }
12224         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12225         CHECK_ACCESS(ret_ptr);
12226         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12227         FREE((void*)ret);
12228         if (get_jenv_res == JNI_EDETACHED) {
12229                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12230         }
12231         return ret_conv;
12232 }
12233 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
12234         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12235         JNIEnv *env;
12236         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12237         if (get_jenv_res == JNI_EDETACHED) {
12238                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12239         } else {
12240                 DO_ASSERT(get_jenv_res == JNI_OK);
12241         }
12242         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12243         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12244         LDKQueryShortChannelIds msg_var = msg;
12245         int64_t msg_ref = 0;
12246         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12247         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12248         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12249         msg_ref = (uintptr_t)msg_var.inner;
12250         if (msg_var.is_owned) {
12251                 msg_ref |= 1;
12252         }
12253         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12254         CHECK(obj != NULL);
12255         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
12256         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12257                 (*env)->ExceptionDescribe(env);
12258                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
12259         }
12260         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12261         CHECK_ACCESS(ret_ptr);
12262         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12263         FREE((void*)ret);
12264         if (get_jenv_res == JNI_EDETACHED) {
12265                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12266         }
12267         return ret_conv;
12268 }
12269 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
12270         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
12271         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12272         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12273 }
12274 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12275         jclass c = (*env)->GetObjectClass(env, o);
12276         CHECK(c != NULL);
12277         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
12278         atomic_init(&calls->refcnt, 1);
12279         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12280         calls->o = (*env)->NewWeakGlobalRef(env, o);
12281         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
12282         CHECK(calls->handle_node_announcement_meth != NULL);
12283         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
12284         CHECK(calls->handle_channel_announcement_meth != NULL);
12285         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
12286         CHECK(calls->handle_channel_update_meth != NULL);
12287         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
12288         CHECK(calls->get_next_channel_announcements_meth != NULL);
12289         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
12290         CHECK(calls->get_next_node_announcements_meth != NULL);
12291         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12292         CHECK(calls->peer_connected_meth != NULL);
12293         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
12294         CHECK(calls->handle_reply_channel_range_meth != NULL);
12295         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
12296         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
12297         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
12298         CHECK(calls->handle_query_channel_range_meth != NULL);
12299         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
12300         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
12301
12302         LDKRoutingMessageHandler ret = {
12303                 .this_arg = (void*) calls,
12304                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
12305                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
12306                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
12307                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
12308                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
12309                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
12310                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
12311                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
12312                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
12313                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
12314                 .free = LDKRoutingMessageHandler_JCalls_free,
12315                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12316         };
12317         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12318         return ret;
12319 }
12320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12321         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
12322         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12323         return (uint64_t)res_ptr;
12324 }
12325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12326         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
12327         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
12328         DO_ASSERT((res_ptr & 1) == 0);
12329         return (int64_t)(res_ptr | 1);
12330 }
12331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12332         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12333         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12334         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12335         LDKNodeAnnouncement msg_conv;
12336         msg_conv.inner = (void*)(msg & (~1));
12337         msg_conv.is_owned = false;
12338         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12339         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12340         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
12341         return (int64_t)ret_conv;
12342 }
12343
12344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12345         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12346         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12347         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12348         LDKChannelAnnouncement msg_conv;
12349         msg_conv.inner = (void*)(msg & (~1));
12350         msg_conv.is_owned = false;
12351         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12352         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12353         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
12354         return (int64_t)ret_conv;
12355 }
12356
12357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
12358         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12359         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12360         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12361         LDKChannelUpdate msg_conv;
12362         msg_conv.inner = (void*)(msg & (~1));
12363         msg_conv.is_owned = false;
12364         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12365         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
12366         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
12367         return (int64_t)ret_conv;
12368 }
12369
12370 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) {
12371         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12372         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12373         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12374         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
12375         int64_tArray ret_arr = NULL;
12376         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12377         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12378         for (size_t h = 0; h < ret_var.datalen; h++) {
12379                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
12380                 *ret_conv_59_conv = ret_var.data[h];
12381                 ret_arr_ptr[h] = ((int64_t)ret_conv_59_conv);
12382         }
12383         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12384         FREE(ret_var.data);
12385         return ret_arr;
12386 }
12387
12388 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) {
12389         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12390         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12391         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12392         LDKPublicKey starting_point_ref;
12393         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
12394         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
12395         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
12396         int64_tArray ret_arr = NULL;
12397         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12398         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12399         for (size_t s = 0; s < ret_var.datalen; s++) {
12400                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
12401                 int64_t ret_conv_18_ref = 0;
12402                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12403                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12404                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
12405                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
12406                 if (ret_conv_18_var.is_owned) {
12407                         ret_conv_18_ref |= 1;
12408                 }
12409                 ret_arr_ptr[s] = ret_conv_18_ref;
12410         }
12411         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12412         FREE(ret_var.data);
12413         return ret_arr;
12414 }
12415
12416 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) {
12417         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12418         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12419         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12420         LDKPublicKey their_node_id_ref;
12421         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12422         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12423         LDKInit init_conv;
12424         init_conv.inner = (void*)(init & (~1));
12425         init_conv.is_owned = false;
12426         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
12427         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
12428 }
12429
12430 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) {
12431         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12432         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12433         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12434         LDKPublicKey their_node_id_ref;
12435         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12436         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12437         LDKReplyChannelRange msg_conv;
12438         msg_conv.inner = (void*)(msg & (~1));
12439         msg_conv.is_owned = (msg & 1) || (msg == 0);
12440         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12441         msg_conv = ReplyChannelRange_clone(&msg_conv);
12442         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12443         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12444         return (int64_t)ret_conv;
12445 }
12446
12447 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) {
12448         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12449         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12450         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12451         LDKPublicKey their_node_id_ref;
12452         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12453         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12454         LDKReplyShortChannelIdsEnd msg_conv;
12455         msg_conv.inner = (void*)(msg & (~1));
12456         msg_conv.is_owned = (msg & 1) || (msg == 0);
12457         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12458         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
12459         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12460         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12461         return (int64_t)ret_conv;
12462 }
12463
12464 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) {
12465         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12466         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12467         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12468         LDKPublicKey their_node_id_ref;
12469         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12470         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12471         LDKQueryChannelRange msg_conv;
12472         msg_conv.inner = (void*)(msg & (~1));
12473         msg_conv.is_owned = (msg & 1) || (msg == 0);
12474         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12475         msg_conv = QueryChannelRange_clone(&msg_conv);
12476         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12477         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12478         return (int64_t)ret_conv;
12479 }
12480
12481 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) {
12482         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12483         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12484         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
12485         LDKPublicKey their_node_id_ref;
12486         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12487         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12488         LDKQueryShortChannelIds msg_conv;
12489         msg_conv.inner = (void*)(msg & (~1));
12490         msg_conv.is_owned = (msg & 1) || (msg == 0);
12491         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12492         msg_conv = QueryShortChannelIds_clone(&msg_conv);
12493         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12494         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
12495         return (int64_t)ret_conv;
12496 }
12497
12498 typedef struct LDKCustomMessageReader_JCalls {
12499         atomic_size_t refcnt;
12500         JavaVM *vm;
12501         jweak o;
12502         jmethodID read_meth;
12503 } LDKCustomMessageReader_JCalls;
12504 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
12505         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
12506         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12507                 JNIEnv *env;
12508                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12509                 if (get_jenv_res == JNI_EDETACHED) {
12510                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12511                 } else {
12512                         DO_ASSERT(get_jenv_res == JNI_OK);
12513                 }
12514                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12515                 if (get_jenv_res == JNI_EDETACHED) {
12516                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12517                 }
12518                 FREE(j_calls);
12519         }
12520 }
12521 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
12522         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
12523         JNIEnv *env;
12524         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12525         if (get_jenv_res == JNI_EDETACHED) {
12526                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12527         } else {
12528                 DO_ASSERT(get_jenv_res == JNI_OK);
12529         }
12530         int16_t message_type_conv = message_type;
12531         LDKu8slice buffer_var = buffer;
12532         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
12533         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
12534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12535         CHECK(obj != NULL);
12536         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
12537         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12538                 (*env)->ExceptionDescribe(env);
12539                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
12540         }
12541         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12542         CHECK_ACCESS(ret_ptr);
12543         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
12544         FREE((void*)ret);
12545         if (get_jenv_res == JNI_EDETACHED) {
12546                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12547         }
12548         return ret_conv;
12549 }
12550 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
12551         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
12552         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12553 }
12554 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
12555         jclass c = (*env)->GetObjectClass(env, o);
12556         CHECK(c != NULL);
12557         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
12558         atomic_init(&calls->refcnt, 1);
12559         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12560         calls->o = (*env)->NewWeakGlobalRef(env, o);
12561         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
12562         CHECK(calls->read_meth != NULL);
12563
12564         LDKCustomMessageReader ret = {
12565                 .this_arg = (void*) calls,
12566                 .read = read_LDKCustomMessageReader_jcall,
12567                 .free = LDKCustomMessageReader_JCalls_free,
12568         };
12569         return ret;
12570 }
12571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
12572         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
12573         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
12574         return (uint64_t)res_ptr;
12575 }
12576 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) {
12577         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12578         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12579         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
12580         LDKu8slice buffer_ref;
12581         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
12582         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
12583         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12584         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
12585         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
12586         return (int64_t)ret_conv;
12587 }
12588
12589 typedef struct LDKCustomMessageHandler_JCalls {
12590         atomic_size_t refcnt;
12591         JavaVM *vm;
12592         jweak o;
12593         LDKCustomMessageReader_JCalls* CustomMessageReader;
12594         jmethodID handle_custom_message_meth;
12595         jmethodID get_and_clear_pending_msg_meth;
12596 } LDKCustomMessageHandler_JCalls;
12597 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
12598         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12599         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12600                 JNIEnv *env;
12601                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12602                 if (get_jenv_res == JNI_EDETACHED) {
12603                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12604                 } else {
12605                         DO_ASSERT(get_jenv_res == JNI_OK);
12606                 }
12607                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12608                 if (get_jenv_res == JNI_EDETACHED) {
12609                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12610                 }
12611                 FREE(j_calls);
12612         }
12613 }
12614 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
12615         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12616         JNIEnv *env;
12617         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12618         if (get_jenv_res == JNI_EDETACHED) {
12619                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12620         } else {
12621                 DO_ASSERT(get_jenv_res == JNI_OK);
12622         }
12623         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
12624         *msg_ret = msg;
12625         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
12626         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
12627         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12628         CHECK(obj != NULL);
12629         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (int64_t)msg_ret, sender_node_id_arr);
12630         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12631                 (*env)->ExceptionDescribe(env);
12632                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
12633         }
12634         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
12635         CHECK_ACCESS(ret_ptr);
12636         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12637         FREE((void*)ret);
12638         if (get_jenv_res == JNI_EDETACHED) {
12639                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12640         }
12641         return ret_conv;
12642 }
12643 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
12644         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
12645         JNIEnv *env;
12646         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12647         if (get_jenv_res == JNI_EDETACHED) {
12648                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12649         } else {
12650                 DO_ASSERT(get_jenv_res == JNI_OK);
12651         }
12652         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12653         CHECK(obj != NULL);
12654         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
12655         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12656                 (*env)->ExceptionDescribe(env);
12657                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
12658         }
12659         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
12660         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
12661         if (ret_constr.datalen > 0)
12662                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
12663         else
12664                 ret_constr.data = NULL;
12665         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
12666         for (size_t z = 0; z < ret_constr.datalen; z++) {
12667                 int64_t ret_conv_25 = ret_vals[z];
12668                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
12669                 CHECK_ACCESS(ret_conv_25_ptr);
12670                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
12671                 FREE((void*)ret_conv_25);
12672                 ret_constr.data[z] = ret_conv_25_conv;
12673         }
12674         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
12675         if (get_jenv_res == JNI_EDETACHED) {
12676                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12677         }
12678         return ret_constr;
12679 }
12680 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
12681         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
12682         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12683         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
12684 }
12685 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12686         jclass c = (*env)->GetObjectClass(env, o);
12687         CHECK(c != NULL);
12688         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
12689         atomic_init(&calls->refcnt, 1);
12690         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12691         calls->o = (*env)->NewWeakGlobalRef(env, o);
12692         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
12693         CHECK(calls->handle_custom_message_meth != NULL);
12694         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
12695         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
12696
12697         LDKCustomMessageHandler ret = {
12698                 .this_arg = (void*) calls,
12699                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
12700                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
12701                 .free = LDKCustomMessageHandler_JCalls_free,
12702                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
12703         };
12704         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
12705         return ret;
12706 }
12707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
12708         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
12709         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
12710         return (uint64_t)res_ptr;
12711 }
12712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
12713         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
12714         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
12715         DO_ASSERT((res_ptr & 1) == 0);
12716         return (int64_t)(res_ptr | 1);
12717 }
12718 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) {
12719         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12720         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12721         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12722         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
12723         CHECK_ACCESS(msg_ptr);
12724         LDKType msg_conv = *(LDKType*)(msg_ptr);
12725         if (msg_conv.free == LDKType_JCalls_free) {
12726                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12727                 LDKType_JCalls_cloned(&msg_conv);
12728         }
12729         LDKPublicKey sender_node_id_ref;
12730         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
12731         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
12732         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
12733         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
12734         return (int64_t)ret_conv;
12735 }
12736
12737 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
12738         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12739         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12740         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
12741         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
12742         int64_tArray ret_arr = NULL;
12743         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
12744         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
12745         for (size_t z = 0; z < ret_var.datalen; z++) {
12746                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
12747                 *ret_conv_25_conv = ret_var.data[z];
12748                 ret_arr_ptr[z] = ((int64_t)ret_conv_25_conv);
12749         }
12750         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
12751         FREE(ret_var.data);
12752         return ret_arr;
12753 }
12754
12755 typedef struct LDKSocketDescriptor_JCalls {
12756         atomic_size_t refcnt;
12757         JavaVM *vm;
12758         jweak o;
12759         jmethodID send_data_meth;
12760         jmethodID disconnect_socket_meth;
12761         jmethodID eq_meth;
12762         jmethodID hash_meth;
12763 } LDKSocketDescriptor_JCalls;
12764 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
12765         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12766         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12767                 JNIEnv *env;
12768                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12769                 if (get_jenv_res == JNI_EDETACHED) {
12770                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12771                 } else {
12772                         DO_ASSERT(get_jenv_res == JNI_OK);
12773                 }
12774                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12775                 if (get_jenv_res == JNI_EDETACHED) {
12776                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12777                 }
12778                 FREE(j_calls);
12779         }
12780 }
12781 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
12782         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12783         JNIEnv *env;
12784         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12785         if (get_jenv_res == JNI_EDETACHED) {
12786                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12787         } else {
12788                 DO_ASSERT(get_jenv_res == JNI_OK);
12789         }
12790         LDKu8slice data_var = data;
12791         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
12792         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
12793         jboolean resume_read_conv = resume_read;
12794         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12795         CHECK(obj != NULL);
12796         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
12797         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12798                 (*env)->ExceptionDescribe(env);
12799                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
12800         }
12801         if (get_jenv_res == JNI_EDETACHED) {
12802                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12803         }
12804         return ret;
12805 }
12806 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
12807         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12808         JNIEnv *env;
12809         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12810         if (get_jenv_res == JNI_EDETACHED) {
12811                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12812         } else {
12813                 DO_ASSERT(get_jenv_res == JNI_OK);
12814         }
12815         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12816         CHECK(obj != NULL);
12817         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
12818         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12819                 (*env)->ExceptionDescribe(env);
12820                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
12821         }
12822         if (get_jenv_res == JNI_EDETACHED) {
12823                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12824         }
12825 }
12826 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
12827         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12828         JNIEnv *env;
12829         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12830         if (get_jenv_res == JNI_EDETACHED) {
12831                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12832         } else {
12833                 DO_ASSERT(get_jenv_res == JNI_OK);
12834         }
12835         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12836         *other_arg_clone = SocketDescriptor_clone(other_arg);
12837         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12838         CHECK(obj != NULL);
12839         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (int64_t)other_arg_clone);
12840         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12841                 (*env)->ExceptionDescribe(env);
12842                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
12843         }
12844         if (get_jenv_res == JNI_EDETACHED) {
12845                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12846         }
12847         return ret;
12848 }
12849 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
12850         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
12851         JNIEnv *env;
12852         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12853         if (get_jenv_res == JNI_EDETACHED) {
12854                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12855         } else {
12856                 DO_ASSERT(get_jenv_res == JNI_OK);
12857         }
12858         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12859         CHECK(obj != NULL);
12860         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
12861         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12862                 (*env)->ExceptionDescribe(env);
12863                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
12864         }
12865         if (get_jenv_res == JNI_EDETACHED) {
12866                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12867         }
12868         return ret;
12869 }
12870 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
12871         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
12872         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12873 }
12874 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
12875         jclass c = (*env)->GetObjectClass(env, o);
12876         CHECK(c != NULL);
12877         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
12878         atomic_init(&calls->refcnt, 1);
12879         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12880         calls->o = (*env)->NewWeakGlobalRef(env, o);
12881         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
12882         CHECK(calls->send_data_meth != NULL);
12883         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
12884         CHECK(calls->disconnect_socket_meth != NULL);
12885         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
12886         CHECK(calls->eq_meth != NULL);
12887         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
12888         CHECK(calls->hash_meth != NULL);
12889
12890         LDKSocketDescriptor ret = {
12891                 .this_arg = (void*) calls,
12892                 .send_data = send_data_LDKSocketDescriptor_jcall,
12893                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
12894                 .eq = eq_LDKSocketDescriptor_jcall,
12895                 .hash = hash_LDKSocketDescriptor_jcall,
12896                 .cloned = LDKSocketDescriptor_JCalls_cloned,
12897                 .free = LDKSocketDescriptor_JCalls_free,
12898         };
12899         return ret;
12900 }
12901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
12902         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12903         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
12904         return (uint64_t)res_ptr;
12905 }
12906 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) {
12907         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12908         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12909         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12910         LDKu8slice data_ref;
12911         data_ref.datalen = (*env)->GetArrayLength(env, data);
12912         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
12913         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
12914         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
12915         return ret_conv;
12916 }
12917
12918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
12919         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12920         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12921         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12922         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
12923 }
12924
12925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
12926         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
12927         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
12928         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
12929         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
12930         return ret_conv;
12931 }
12932
12933 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
12934 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
12935 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
12936 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
12937 static jclass LDKEffectiveCapacity_Total_class = NULL;
12938 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
12939 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
12940 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
12941 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
12942 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
12943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
12944         LDKEffectiveCapacity_ExactLiquidity_class =
12945                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
12946         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
12947         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
12948         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
12949         LDKEffectiveCapacity_MaximumHTLC_class =
12950                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
12951         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
12952         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
12953         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
12954         LDKEffectiveCapacity_Total_class =
12955                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
12956         CHECK(LDKEffectiveCapacity_Total_class != NULL);
12957         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(J)V");
12958         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
12959         LDKEffectiveCapacity_Infinite_class =
12960                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
12961         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
12962         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
12963         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
12964         LDKEffectiveCapacity_Unknown_class =
12965                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
12966         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
12967         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
12968         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
12969 }
12970 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
12971         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
12972         switch(obj->tag) {
12973                 case LDKEffectiveCapacity_ExactLiquidity: {
12974                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
12975                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
12976                 }
12977                 case LDKEffectiveCapacity_MaximumHTLC: {
12978                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
12979                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
12980                 }
12981                 case LDKEffectiveCapacity_Total: {
12982                         int64_t capacity_msat_conv = obj->total.capacity_msat;
12983                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv);
12984                 }
12985                 case LDKEffectiveCapacity_Infinite: {
12986                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
12987                 }
12988                 case LDKEffectiveCapacity_Unknown: {
12989                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
12990                 }
12991                 default: abort();
12992         }
12993 }
12994 typedef struct LDKScore_JCalls {
12995         atomic_size_t refcnt;
12996         JavaVM *vm;
12997         jweak o;
12998         jmethodID channel_penalty_msat_meth;
12999         jmethodID payment_path_failed_meth;
13000         jmethodID payment_path_successful_meth;
13001         jmethodID write_meth;
13002 } LDKScore_JCalls;
13003 static void LDKScore_JCalls_free(void* this_arg) {
13004         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13005         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13006                 JNIEnv *env;
13007                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13008                 if (get_jenv_res == JNI_EDETACHED) {
13009                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13010                 } else {
13011                         DO_ASSERT(get_jenv_res == JNI_OK);
13012                 }
13013                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13014                 if (get_jenv_res == JNI_EDETACHED) {
13015                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13016                 }
13017                 FREE(j_calls);
13018         }
13019 }
13020 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, uint64_t capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
13021         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13022         JNIEnv *env;
13023         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13024         if (get_jenv_res == JNI_EDETACHED) {
13025                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13026         } else {
13027                 DO_ASSERT(get_jenv_res == JNI_OK);
13028         }
13029         int64_t short_channel_id_conv = short_channel_id;
13030         int64_t send_amt_msat_conv = send_amt_msat;
13031         int64_t capacity_msat_conv = capacity_msat;
13032         LDKNodeId source_var = *source;
13033         int64_t source_ref = 0;
13034         source_var = NodeId_clone(&source_var);
13035         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13036         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13037         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
13038         source_ref = (uintptr_t)source_var.inner;
13039         if (source_var.is_owned) {
13040                 source_ref |= 1;
13041         }
13042         LDKNodeId target_var = *target;
13043         int64_t target_ref = 0;
13044         target_var = NodeId_clone(&target_var);
13045         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13046         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13047         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
13048         target_ref = (uintptr_t)target_var.inner;
13049         if (target_var.is_owned) {
13050                 target_ref |= 1;
13051         }
13052         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13053         CHECK(obj != NULL);
13054         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, send_amt_msat_conv, capacity_msat_conv, source_ref, target_ref);
13055         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13056                 (*env)->ExceptionDescribe(env);
13057                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
13058         }
13059         if (get_jenv_res == JNI_EDETACHED) {
13060                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13061         }
13062         return ret;
13063 }
13064 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
13065         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13066         JNIEnv *env;
13067         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13068         if (get_jenv_res == JNI_EDETACHED) {
13069                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13070         } else {
13071                 DO_ASSERT(get_jenv_res == JNI_OK);
13072         }
13073         LDKCVec_RouteHopZ path_var = path;
13074         int64_tArray path_arr = NULL;
13075         path_arr = (*env)->NewLongArray(env, path_var.datalen);
13076         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
13077         for (size_t k = 0; k < path_var.datalen; k++) {
13078                 LDKRouteHop path_conv_10_var = path_var.data[k];
13079                 int64_t path_conv_10_ref = 0;
13080                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13081                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13082                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
13083                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
13084                 if (path_conv_10_var.is_owned) {
13085                         path_conv_10_ref |= 1;
13086                 }
13087                 path_arr_ptr[k] = path_conv_10_ref;
13088         }
13089         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
13090         FREE(path_var.data);
13091         int64_t short_channel_id_conv = short_channel_id;
13092         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13093         CHECK(obj != NULL);
13094         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
13095         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13096                 (*env)->ExceptionDescribe(env);
13097                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
13098         }
13099         if (get_jenv_res == JNI_EDETACHED) {
13100                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13101         }
13102 }
13103 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
13104         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13105         JNIEnv *env;
13106         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13107         if (get_jenv_res == JNI_EDETACHED) {
13108                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13109         } else {
13110                 DO_ASSERT(get_jenv_res == JNI_OK);
13111         }
13112         LDKCVec_RouteHopZ path_var = path;
13113         int64_tArray path_arr = NULL;
13114         path_arr = (*env)->NewLongArray(env, path_var.datalen);
13115         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
13116         for (size_t k = 0; k < path_var.datalen; k++) {
13117                 LDKRouteHop path_conv_10_var = path_var.data[k];
13118                 int64_t path_conv_10_ref = 0;
13119                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13120                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13121                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
13122                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
13123                 if (path_conv_10_var.is_owned) {
13124                         path_conv_10_ref |= 1;
13125                 }
13126                 path_arr_ptr[k] = path_conv_10_ref;
13127         }
13128         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
13129         FREE(path_var.data);
13130         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13131         CHECK(obj != NULL);
13132         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
13133         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13134                 (*env)->ExceptionDescribe(env);
13135                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
13136         }
13137         if (get_jenv_res == JNI_EDETACHED) {
13138                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13139         }
13140 }
13141 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
13142         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
13143         JNIEnv *env;
13144         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13145         if (get_jenv_res == JNI_EDETACHED) {
13146                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13147         } else {
13148                 DO_ASSERT(get_jenv_res == JNI_OK);
13149         }
13150         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13151         CHECK(obj != NULL);
13152         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
13153         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13154                 (*env)->ExceptionDescribe(env);
13155                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
13156         }
13157         LDKCVec_u8Z ret_ref;
13158         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
13159         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
13160         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
13161         if (get_jenv_res == JNI_EDETACHED) {
13162                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13163         }
13164         return ret_ref;
13165 }
13166 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
13167         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
13168         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13169 }
13170 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
13171         jclass c = (*env)->GetObjectClass(env, o);
13172         CHECK(c != NULL);
13173         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
13174         atomic_init(&calls->refcnt, 1);
13175         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13176         calls->o = (*env)->NewWeakGlobalRef(env, o);
13177         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJJ)J");
13178         CHECK(calls->channel_penalty_msat_meth != NULL);
13179         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
13180         CHECK(calls->payment_path_failed_meth != NULL);
13181         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
13182         CHECK(calls->payment_path_successful_meth != NULL);
13183         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
13184         CHECK(calls->write_meth != NULL);
13185
13186         LDKScore ret = {
13187                 .this_arg = (void*) calls,
13188                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
13189                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
13190                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
13191                 .write = write_LDKScore_jcall,
13192                 .free = LDKScore_JCalls_free,
13193         };
13194         return ret;
13195 }
13196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
13197         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
13198         *res_ptr = LDKScore_init(env, clz, o);
13199         return (uint64_t)res_ptr;
13200 }
13201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t send_amt_msat, int64_t capacity_msat, int64_t source, int64_t target) {
13202         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13203         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13204         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13205         LDKNodeId source_conv;
13206         source_conv.inner = (void*)(source & (~1));
13207         source_conv.is_owned = false;
13208         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
13209         LDKNodeId target_conv;
13210         target_conv.inner = (void*)(target & (~1));
13211         target_conv.is_owned = false;
13212         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
13213         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, capacity_msat, &source_conv, &target_conv);
13214         return ret_conv;
13215 }
13216
13217 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) {
13218         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13219         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13220         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13221         LDKCVec_RouteHopZ path_constr;
13222         path_constr.datalen = (*env)->GetArrayLength(env, path);
13223         if (path_constr.datalen > 0)
13224                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
13225         else
13226                 path_constr.data = NULL;
13227         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
13228         for (size_t k = 0; k < path_constr.datalen; k++) {
13229                 int64_t path_conv_10 = path_vals[k];
13230                 LDKRouteHop path_conv_10_conv;
13231                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
13232                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
13233                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
13234                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
13235                 path_constr.data[k] = path_conv_10_conv;
13236         }
13237         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
13238         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
13239 }
13240
13241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
13242         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13243         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13244         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13245         LDKCVec_RouteHopZ path_constr;
13246         path_constr.datalen = (*env)->GetArrayLength(env, path);
13247         if (path_constr.datalen > 0)
13248                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
13249         else
13250                 path_constr.data = NULL;
13251         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
13252         for (size_t k = 0; k < path_constr.datalen; k++) {
13253                 int64_t path_conv_10 = path_vals[k];
13254                 LDKRouteHop path_conv_10_conv;
13255                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
13256                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
13257                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
13258                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
13259                 path_constr.data[k] = path_conv_10_conv;
13260         }
13261         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
13262         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
13263 }
13264
13265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
13266         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13267         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13268         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
13269         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
13270         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
13271         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
13272         CVec_u8Z_free(ret_var);
13273         return ret_arr;
13274 }
13275
13276 typedef struct LDKLockableScore_JCalls {
13277         atomic_size_t refcnt;
13278         JavaVM *vm;
13279         jweak o;
13280         jmethodID lock_meth;
13281 } LDKLockableScore_JCalls;
13282 static void LDKLockableScore_JCalls_free(void* this_arg) {
13283         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13284         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13285                 JNIEnv *env;
13286                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13287                 if (get_jenv_res == JNI_EDETACHED) {
13288                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13289                 } else {
13290                         DO_ASSERT(get_jenv_res == JNI_OK);
13291                 }
13292                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13293                 if (get_jenv_res == JNI_EDETACHED) {
13294                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13295                 }
13296                 FREE(j_calls);
13297         }
13298 }
13299 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
13300         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
13301         JNIEnv *env;
13302         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13303         if (get_jenv_res == JNI_EDETACHED) {
13304                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13305         } else {
13306                 DO_ASSERT(get_jenv_res == JNI_OK);
13307         }
13308         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13309         CHECK(obj != NULL);
13310         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
13311         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13312                 (*env)->ExceptionDescribe(env);
13313                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
13314         }
13315         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13316         CHECK_ACCESS(ret_ptr);
13317         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
13318         if (ret_conv.free == LDKScore_JCalls_free) {
13319                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13320                 LDKScore_JCalls_cloned(&ret_conv);
13321         }// WARNING: we may need a move here but no clone is available for LDKScore
13322         
13323         if (get_jenv_res == JNI_EDETACHED) {
13324                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13325         }
13326         return ret_conv;
13327 }
13328 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
13329         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
13330         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13331 }
13332 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
13333         jclass c = (*env)->GetObjectClass(env, o);
13334         CHECK(c != NULL);
13335         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
13336         atomic_init(&calls->refcnt, 1);
13337         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13338         calls->o = (*env)->NewWeakGlobalRef(env, o);
13339         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
13340         CHECK(calls->lock_meth != NULL);
13341
13342         LDKLockableScore ret = {
13343                 .this_arg = (void*) calls,
13344                 .lock = lock_LDKLockableScore_jcall,
13345                 .free = LDKLockableScore_JCalls_free,
13346         };
13347         return ret;
13348 }
13349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
13350         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
13351         *res_ptr = LDKLockableScore_init(env, clz, o);
13352         return (uint64_t)res_ptr;
13353 }
13354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
13355         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13356         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13357         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
13358         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
13359         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
13360         return (int64_t)ret_ret;
13361 }
13362
13363 typedef struct LDKPersister_JCalls {
13364         atomic_size_t refcnt;
13365         JavaVM *vm;
13366         jweak o;
13367         jmethodID persist_manager_meth;
13368         jmethodID persist_graph_meth;
13369 } LDKPersister_JCalls;
13370 static void LDKPersister_JCalls_free(void* this_arg) {
13371         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
13372         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13373                 JNIEnv *env;
13374                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13375                 if (get_jenv_res == JNI_EDETACHED) {
13376                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13377                 } else {
13378                         DO_ASSERT(get_jenv_res == JNI_OK);
13379                 }
13380                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13381                 if (get_jenv_res == JNI_EDETACHED) {
13382                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13383                 }
13384                 FREE(j_calls);
13385         }
13386 }
13387 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
13388         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
13389         JNIEnv *env;
13390         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13391         if (get_jenv_res == JNI_EDETACHED) {
13392                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13393         } else {
13394                 DO_ASSERT(get_jenv_res == JNI_OK);
13395         }
13396         LDKChannelManager channel_manager_var = *channel_manager;
13397         int64_t channel_manager_ref = 0;
13398         // WARNING: we may need a move here but no clone is available for LDKChannelManager
13399         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13400         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13401         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
13402         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
13403         if (channel_manager_var.is_owned) {
13404                 channel_manager_ref |= 1;
13405         }
13406         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13407         CHECK(obj != NULL);
13408         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
13409         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13410                 (*env)->ExceptionDescribe(env);
13411                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
13412         }
13413         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13414         CHECK_ACCESS(ret_ptr);
13415         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
13416         FREE((void*)ret);
13417         if (get_jenv_res == JNI_EDETACHED) {
13418                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13419         }
13420         return ret_conv;
13421 }
13422 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
13423         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
13424         JNIEnv *env;
13425         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13426         if (get_jenv_res == JNI_EDETACHED) {
13427                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13428         } else {
13429                 DO_ASSERT(get_jenv_res == JNI_OK);
13430         }
13431         LDKNetworkGraph network_graph_var = *network_graph;
13432         int64_t network_graph_ref = 0;
13433         network_graph_var = NetworkGraph_clone(&network_graph_var);
13434         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13435         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13436         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
13437         network_graph_ref = (uintptr_t)network_graph_var.inner;
13438         if (network_graph_var.is_owned) {
13439                 network_graph_ref |= 1;
13440         }
13441         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13442         CHECK(obj != NULL);
13443         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
13444         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13445                 (*env)->ExceptionDescribe(env);
13446                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
13447         }
13448         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13449         CHECK_ACCESS(ret_ptr);
13450         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
13451         FREE((void*)ret);
13452         if (get_jenv_res == JNI_EDETACHED) {
13453                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13454         }
13455         return ret_conv;
13456 }
13457 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
13458         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
13459         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13460 }
13461 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
13462         jclass c = (*env)->GetObjectClass(env, o);
13463         CHECK(c != NULL);
13464         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
13465         atomic_init(&calls->refcnt, 1);
13466         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13467         calls->o = (*env)->NewWeakGlobalRef(env, o);
13468         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
13469         CHECK(calls->persist_manager_meth != NULL);
13470         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
13471         CHECK(calls->persist_graph_meth != NULL);
13472
13473         LDKPersister ret = {
13474                 .this_arg = (void*) calls,
13475                 .persist_manager = persist_manager_LDKPersister_jcall,
13476                 .persist_graph = persist_graph_LDKPersister_jcall,
13477                 .free = LDKPersister_JCalls_free,
13478         };
13479         return ret;
13480 }
13481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
13482         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
13483         *res_ptr = LDKPersister_init(env, clz, o);
13484         return (uint64_t)res_ptr;
13485 }
13486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
13487         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13488         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13489         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
13490         LDKChannelManager channel_manager_conv;
13491         channel_manager_conv.inner = (void*)(channel_manager & (~1));
13492         channel_manager_conv.is_owned = false;
13493         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
13494         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
13495         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
13496         return (int64_t)ret_conv;
13497 }
13498
13499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
13500         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13501         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13502         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
13503         LDKNetworkGraph network_graph_conv;
13504         network_graph_conv.inner = (void*)(network_graph & (~1));
13505         network_graph_conv.is_owned = false;
13506         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
13507         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
13508         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
13509         return (int64_t)ret_conv;
13510 }
13511
13512 static jclass LDKFallback_SegWitProgram_class = NULL;
13513 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
13514 static jclass LDKFallback_PubKeyHash_class = NULL;
13515 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
13516 static jclass LDKFallback_ScriptHash_class = NULL;
13517 static jmethodID LDKFallback_ScriptHash_meth = NULL;
13518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
13519         LDKFallback_SegWitProgram_class =
13520                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
13521         CHECK(LDKFallback_SegWitProgram_class != NULL);
13522         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
13523         CHECK(LDKFallback_SegWitProgram_meth != NULL);
13524         LDKFallback_PubKeyHash_class =
13525                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
13526         CHECK(LDKFallback_PubKeyHash_class != NULL);
13527         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
13528         CHECK(LDKFallback_PubKeyHash_meth != NULL);
13529         LDKFallback_ScriptHash_class =
13530                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
13531         CHECK(LDKFallback_ScriptHash_class != NULL);
13532         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
13533         CHECK(LDKFallback_ScriptHash_meth != NULL);
13534 }
13535 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
13536         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
13537         switch(obj->tag) {
13538                 case LDKFallback_SegWitProgram: {
13539                         uint8_t version_val = obj->seg_wit_program.version._0;
13540                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
13541                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
13542                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
13543                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
13544                 }
13545                 case LDKFallback_PubKeyHash: {
13546                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
13547                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
13548                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
13549                 }
13550                 case LDKFallback_ScriptHash: {
13551                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
13552                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
13553                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
13554                 }
13555                 default: abort();
13556         }
13557 }
13558 typedef struct LDKPayer_JCalls {
13559         atomic_size_t refcnt;
13560         JavaVM *vm;
13561         jweak o;
13562         jmethodID node_id_meth;
13563         jmethodID first_hops_meth;
13564         jmethodID send_payment_meth;
13565         jmethodID send_spontaneous_payment_meth;
13566         jmethodID retry_payment_meth;
13567         jmethodID abandon_payment_meth;
13568 } LDKPayer_JCalls;
13569 static void LDKPayer_JCalls_free(void* this_arg) {
13570         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13571         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13572                 JNIEnv *env;
13573                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13574                 if (get_jenv_res == JNI_EDETACHED) {
13575                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13576                 } else {
13577                         DO_ASSERT(get_jenv_res == JNI_OK);
13578                 }
13579                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13580                 if (get_jenv_res == JNI_EDETACHED) {
13581                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13582                 }
13583                 FREE(j_calls);
13584         }
13585 }
13586 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
13587         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13588         JNIEnv *env;
13589         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13590         if (get_jenv_res == JNI_EDETACHED) {
13591                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13592         } else {
13593                 DO_ASSERT(get_jenv_res == JNI_OK);
13594         }
13595         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13596         CHECK(obj != NULL);
13597         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
13598         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13599                 (*env)->ExceptionDescribe(env);
13600                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
13601         }
13602         LDKPublicKey ret_ref;
13603         CHECK((*env)->GetArrayLength(env, ret) == 33);
13604         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
13605         if (get_jenv_res == JNI_EDETACHED) {
13606                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13607         }
13608         return ret_ref;
13609 }
13610 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
13611         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13612         JNIEnv *env;
13613         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13614         if (get_jenv_res == JNI_EDETACHED) {
13615                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13616         } else {
13617                 DO_ASSERT(get_jenv_res == JNI_OK);
13618         }
13619         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13620         CHECK(obj != NULL);
13621         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
13622         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13623                 (*env)->ExceptionDescribe(env);
13624                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
13625         }
13626         LDKCVec_ChannelDetailsZ ret_constr;
13627         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13628         if (ret_constr.datalen > 0)
13629                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13630         else
13631                 ret_constr.data = NULL;
13632         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13633         for (size_t q = 0; q < ret_constr.datalen; q++) {
13634                 int64_t ret_conv_16 = ret_vals[q];
13635                 LDKChannelDetails ret_conv_16_conv;
13636                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
13637                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
13638                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
13639                 ret_constr.data[q] = ret_conv_16_conv;
13640         }
13641         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13642         if (get_jenv_res == JNI_EDETACHED) {
13643                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13644         }
13645         return ret_constr;
13646 }
13647 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
13648         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13649         JNIEnv *env;
13650         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13651         if (get_jenv_res == JNI_EDETACHED) {
13652                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13653         } else {
13654                 DO_ASSERT(get_jenv_res == JNI_OK);
13655         }
13656         LDKRoute route_var = *route;
13657         int64_t route_ref = 0;
13658         route_var = Route_clone(&route_var);
13659         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13660         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13661         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13662         route_ref = (uintptr_t)route_var.inner;
13663         if (route_var.is_owned) {
13664                 route_ref |= 1;
13665         }
13666         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13667         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
13668         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
13669         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
13670         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13671         CHECK(obj != NULL);
13672         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
13673         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13674                 (*env)->ExceptionDescribe(env);
13675                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
13676         }
13677         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13678         CHECK_ACCESS(ret_ptr);
13679         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13680         FREE((void*)ret);
13681         if (get_jenv_res == JNI_EDETACHED) {
13682                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13683         }
13684         return ret_conv;
13685 }
13686 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
13687         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13688         JNIEnv *env;
13689         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13690         if (get_jenv_res == JNI_EDETACHED) {
13691                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13692         } else {
13693                 DO_ASSERT(get_jenv_res == JNI_OK);
13694         }
13695         LDKRoute route_var = *route;
13696         int64_t route_ref = 0;
13697         route_var = Route_clone(&route_var);
13698         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13699         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13700         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13701         route_ref = (uintptr_t)route_var.inner;
13702         if (route_var.is_owned) {
13703                 route_ref |= 1;
13704         }
13705         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
13706         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
13707         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13708         CHECK(obj != NULL);
13709         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
13710         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13711                 (*env)->ExceptionDescribe(env);
13712                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
13713         }
13714         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13715         CHECK_ACCESS(ret_ptr);
13716         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
13717         FREE((void*)ret);
13718         if (get_jenv_res == JNI_EDETACHED) {
13719                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13720         }
13721         return ret_conv;
13722 }
13723 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
13724         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13725         JNIEnv *env;
13726         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13727         if (get_jenv_res == JNI_EDETACHED) {
13728                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13729         } else {
13730                 DO_ASSERT(get_jenv_res == JNI_OK);
13731         }
13732         LDKRoute route_var = *route;
13733         int64_t route_ref = 0;
13734         route_var = Route_clone(&route_var);
13735         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13736         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13737         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
13738         route_ref = (uintptr_t)route_var.inner;
13739         if (route_var.is_owned) {
13740                 route_ref |= 1;
13741         }
13742         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13743         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13744         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13745         CHECK(obj != NULL);
13746         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
13747         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13748                 (*env)->ExceptionDescribe(env);
13749                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
13750         }
13751         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13752         CHECK_ACCESS(ret_ptr);
13753         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
13754         FREE((void*)ret);
13755         if (get_jenv_res == JNI_EDETACHED) {
13756                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13757         }
13758         return ret_conv;
13759 }
13760 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
13761         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
13762         JNIEnv *env;
13763         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13764         if (get_jenv_res == JNI_EDETACHED) {
13765                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13766         } else {
13767                 DO_ASSERT(get_jenv_res == JNI_OK);
13768         }
13769         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
13770         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
13771         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13772         CHECK(obj != NULL);
13773         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
13774         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13775                 (*env)->ExceptionDescribe(env);
13776                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
13777         }
13778         if (get_jenv_res == JNI_EDETACHED) {
13779                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13780         }
13781 }
13782 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
13783         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
13784         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13785 }
13786 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
13787         jclass c = (*env)->GetObjectClass(env, o);
13788         CHECK(c != NULL);
13789         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
13790         atomic_init(&calls->refcnt, 1);
13791         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13792         calls->o = (*env)->NewWeakGlobalRef(env, o);
13793         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
13794         CHECK(calls->node_id_meth != NULL);
13795         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
13796         CHECK(calls->first_hops_meth != NULL);
13797         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
13798         CHECK(calls->send_payment_meth != NULL);
13799         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
13800         CHECK(calls->send_spontaneous_payment_meth != NULL);
13801         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
13802         CHECK(calls->retry_payment_meth != NULL);
13803         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
13804         CHECK(calls->abandon_payment_meth != NULL);
13805
13806         LDKPayer ret = {
13807                 .this_arg = (void*) calls,
13808                 .node_id = node_id_LDKPayer_jcall,
13809                 .first_hops = first_hops_LDKPayer_jcall,
13810                 .send_payment = send_payment_LDKPayer_jcall,
13811                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
13812                 .retry_payment = retry_payment_LDKPayer_jcall,
13813                 .abandon_payment = abandon_payment_LDKPayer_jcall,
13814                 .free = LDKPayer_JCalls_free,
13815         };
13816         return ret;
13817 }
13818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
13819         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
13820         *res_ptr = LDKPayer_init(env, clz, o);
13821         return (uint64_t)res_ptr;
13822 }
13823 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
13824         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13825         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13826         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13827         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
13828         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
13829         return ret_arr;
13830 }
13831
13832 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
13833         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13834         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13835         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13836         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
13837         int64_tArray ret_arr = NULL;
13838         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13839         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13840         for (size_t q = 0; q < ret_var.datalen; q++) {
13841                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
13842                 int64_t ret_conv_16_ref = 0;
13843                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13844                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13845                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
13846                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
13847                 if (ret_conv_16_var.is_owned) {
13848                         ret_conv_16_ref |= 1;
13849                 }
13850                 ret_arr_ptr[q] = ret_conv_16_ref;
13851         }
13852         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13853         FREE(ret_var.data);
13854         return ret_arr;
13855 }
13856
13857 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) {
13858         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13859         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13860         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13861         LDKRoute route_conv;
13862         route_conv.inner = (void*)(route & (~1));
13863         route_conv.is_owned = false;
13864         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13865         LDKThirtyTwoBytes payment_hash_ref;
13866         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
13867         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
13868         LDKThirtyTwoBytes payment_secret_ref;
13869         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
13870         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
13871         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13872         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
13873         return (int64_t)ret_conv;
13874 }
13875
13876 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) {
13877         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13878         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13879         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13880         LDKRoute route_conv;
13881         route_conv.inner = (void*)(route & (~1));
13882         route_conv.is_owned = false;
13883         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13884         LDKThirtyTwoBytes payment_preimage_ref;
13885         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
13886         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
13887         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
13888         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
13889         return (int64_t)ret_conv;
13890 }
13891
13892 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) {
13893         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13894         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13895         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13896         LDKRoute route_conv;
13897         route_conv.inner = (void*)(route & (~1));
13898         route_conv.is_owned = false;
13899         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
13900         LDKThirtyTwoBytes payment_id_ref;
13901         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13902         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13903         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
13904         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
13905         return (int64_t)ret_conv;
13906 }
13907
13908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
13909         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
13910         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
13911         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
13912         LDKThirtyTwoBytes payment_id_ref;
13913         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
13914         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
13915         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
13916 }
13917
13918 typedef struct LDKRouter_JCalls {
13919         atomic_size_t refcnt;
13920         JavaVM *vm;
13921         jweak o;
13922         jmethodID find_route_meth;
13923 } LDKRouter_JCalls;
13924 static void LDKRouter_JCalls_free(void* this_arg) {
13925         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13926         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13927                 JNIEnv *env;
13928                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13929                 if (get_jenv_res == JNI_EDETACHED) {
13930                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13931                 } else {
13932                         DO_ASSERT(get_jenv_res == JNI_OK);
13933                 }
13934                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13935                 if (get_jenv_res == JNI_EDETACHED) {
13936                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13937                 }
13938                 FREE(j_calls);
13939         }
13940 }
13941 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) {
13942         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
13943         JNIEnv *env;
13944         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13945         if (get_jenv_res == JNI_EDETACHED) {
13946                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13947         } else {
13948                 DO_ASSERT(get_jenv_res == JNI_OK);
13949         }
13950         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
13951         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
13952         LDKRouteParameters route_params_var = *route_params;
13953         int64_t route_params_ref = 0;
13954         route_params_var = RouteParameters_clone(&route_params_var);
13955         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13956         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13957         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
13958         route_params_ref = (uintptr_t)route_params_var.inner;
13959         if (route_params_var.is_owned) {
13960                 route_params_ref |= 1;
13961         }
13962         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
13963         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
13964         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
13965         int64_tArray first_hops_arr = NULL;
13966         if (first_hops != NULL) {
13967                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
13968                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
13969                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
13970                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
13971                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
13972                         int64_t first_hops_conv_16_ref = 0;
13973                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13974                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13975                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
13976                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
13977                         if (first_hops_conv_16_var.is_owned) {
13978                                 first_hops_conv_16_ref |= 1;
13979                         }
13980                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
13981                 }
13982                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
13983         }
13984         // WARNING: This object doesn't live past this scope, needs clone!
13985         int64_t ret_scorer = ((uintptr_t)scorer) | 1;
13986         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13987         CHECK(obj != NULL);
13988         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);
13989         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13990                 (*env)->ExceptionDescribe(env);
13991                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
13992         }
13993         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
13994         CHECK_ACCESS(ret_ptr);
13995         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
13996         FREE((void*)ret);
13997         if (get_jenv_res == JNI_EDETACHED) {
13998                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13999         }
14000         return ret_conv;
14001 }
14002 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
14003         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
14004         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14005 }
14006 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
14007         jclass c = (*env)->GetObjectClass(env, o);
14008         CHECK(c != NULL);
14009         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
14010         atomic_init(&calls->refcnt, 1);
14011         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14012         calls->o = (*env)->NewWeakGlobalRef(env, o);
14013         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
14014         CHECK(calls->find_route_meth != NULL);
14015
14016         LDKRouter ret = {
14017                 .this_arg = (void*) calls,
14018                 .find_route = find_route_LDKRouter_jcall,
14019                 .free = LDKRouter_JCalls_free,
14020         };
14021         return ret;
14022 }
14023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
14024         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
14025         *res_ptr = LDKRouter_init(env, clz, o);
14026         return (uint64_t)res_ptr;
14027 }
14028 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) {
14029         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
14030         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
14031         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14032         LDKPublicKey payer_ref;
14033         CHECK((*env)->GetArrayLength(env, payer) == 33);
14034         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
14035         LDKRouteParameters route_params_conv;
14036         route_params_conv.inner = (void*)(route_params & (~1));
14037         route_params_conv.is_owned = false;
14038         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
14039         unsigned char payment_hash_arr[32];
14040         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14041         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
14042         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
14043         LDKCVec_ChannelDetailsZ first_hops_constr;
14044         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
14045         if (first_hops != NULL) {
14046                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
14047                 if (first_hops_constr.datalen > 0)
14048                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14049                 else
14050                         first_hops_constr.data = NULL;
14051                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
14052                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14053                         int64_t first_hops_conv_16 = first_hops_vals[q];
14054                         LDKChannelDetails first_hops_conv_16_conv;
14055                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
14056                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
14057                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
14058                         first_hops_constr.data[q] = first_hops_conv_16_conv;
14059                 }
14060                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
14061                 first_hops_ptr = &first_hops_constr;
14062         }
14063         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
14064         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
14065         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
14066         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14067         *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);
14068         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
14069         return (int64_t)ret_conv;
14070 }
14071
14072 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14073         LDKStr ret_str = _ldk_get_compiled_version();
14074         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14075         Str_free(ret_str);
14076         return ret_conv;
14077 }
14078
14079 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
14080         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
14081         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
14082         Str_free(ret_str);
14083         return ret_conv;
14084 }
14085
14086 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
14087         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14088         *ret_copy = Bech32Error_clone(arg);
14089 int64_t ret_ref = (uintptr_t)ret_copy;
14090         return ret_ref;
14091 }
14092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14093         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
14094         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
14095         return ret_conv;
14096 }
14097
14098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14099         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
14100         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
14101         *ret_copy = Bech32Error_clone(orig_conv);
14102         int64_t ret_ref = (uintptr_t)ret_copy;
14103         return ret_ref;
14104 }
14105
14106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
14107         if ((o & 1) != 0) return;
14108         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14109         CHECK_ACCESS(o_ptr);
14110         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
14111         FREE((void*)o);
14112         Bech32Error_free(o_conv);
14113 }
14114
14115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
14116         LDKTransaction _res_ref;
14117         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
14118         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
14119         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
14120         _res_ref.data_is_owned = true;
14121         Transaction_free(_res_ref);
14122 }
14123
14124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
14125         LDKCVec_u8Z script_pubkey_ref;
14126         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
14127         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
14128         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
14129         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14130         *ret_ref = TxOut_new(script_pubkey_ref, value);
14131         return (int64_t)ret_ref;
14132 }
14133
14134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
14135         if ((_res & 1) != 0) return;
14136         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14137         CHECK_ACCESS(_res_ptr);
14138         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
14139         FREE((void*)_res);
14140         TxOut_free(_res_conv);
14141 }
14142
14143 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
14144         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14145         *ret_ref = TxOut_clone(arg);
14146         return (int64_t)ret_ref;
14147 }
14148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14149         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
14150         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
14151         return ret_conv;
14152 }
14153
14154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14155         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
14156         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
14157         *ret_ref = TxOut_clone(orig_conv);
14158         return (int64_t)ret_ref;
14159 }
14160
14161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
14162         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
14163         Str_free(dummy);
14164 }
14165
14166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
14167         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14168         *ret_conv = CResult_NoneNoneZ_ok();
14169         return (int64_t)ret_conv;
14170 }
14171
14172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
14173         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14174         *ret_conv = CResult_NoneNoneZ_err();
14175         return (int64_t)ret_conv;
14176 }
14177
14178 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14179         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
14180         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
14181         return ret_conv;
14182 }
14183
14184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14185         if ((_res & 1) != 0) return;
14186         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14187         CHECK_ACCESS(_res_ptr);
14188         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
14189         FREE((void*)_res);
14190         CResult_NoneNoneZ_free(_res_conv);
14191 }
14192
14193 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
14194         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14195         *ret_conv = CResult_NoneNoneZ_clone(arg);
14196         return (int64_t)ret_conv;
14197 }
14198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14199         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
14200         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
14201         return ret_conv;
14202 }
14203
14204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14205         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
14206         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14207         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
14208         return (int64_t)ret_conv;
14209 }
14210
14211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14212         LDKCounterpartyCommitmentSecrets o_conv;
14213         o_conv.inner = (void*)(o & (~1));
14214         o_conv.is_owned = (o & 1) || (o == 0);
14215         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14216         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
14217         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14218         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
14219         return (int64_t)ret_conv;
14220 }
14221
14222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14223         LDKDecodeError e_conv;
14224         e_conv.inner = (void*)(e & (~1));
14225         e_conv.is_owned = (e & 1) || (e == 0);
14226         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14227         e_conv = DecodeError_clone(&e_conv);
14228         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14229         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
14230         return (int64_t)ret_conv;
14231 }
14232
14233 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14234         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
14235         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
14236         return ret_conv;
14237 }
14238
14239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14240         if ((_res & 1) != 0) return;
14241         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14242         CHECK_ACCESS(_res_ptr);
14243         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
14244         FREE((void*)_res);
14245         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
14246 }
14247
14248 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
14249         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14250         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
14251         return (int64_t)ret_conv;
14252 }
14253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14254         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
14255         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
14256         return ret_conv;
14257 }
14258
14259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14260         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
14261         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
14262         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
14263         return (int64_t)ret_conv;
14264 }
14265
14266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14267         LDKSecretKey o_ref;
14268         CHECK((*env)->GetArrayLength(env, o) == 32);
14269         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
14270         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14271         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
14272         return (int64_t)ret_conv;
14273 }
14274
14275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14276         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14277         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14278         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
14279         return (int64_t)ret_conv;
14280 }
14281
14282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14283         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
14284         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
14285         return ret_conv;
14286 }
14287
14288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14289         if ((_res & 1) != 0) return;
14290         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14291         CHECK_ACCESS(_res_ptr);
14292         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
14293         FREE((void*)_res);
14294         CResult_SecretKeyErrorZ_free(_res_conv);
14295 }
14296
14297 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
14298         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14299         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
14300         return (int64_t)ret_conv;
14301 }
14302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14303         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
14304         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
14305         return ret_conv;
14306 }
14307
14308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14309         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
14310         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
14311         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
14312         return (int64_t)ret_conv;
14313 }
14314
14315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14316         LDKPublicKey o_ref;
14317         CHECK((*env)->GetArrayLength(env, o) == 33);
14318         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
14319         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14320         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
14321         return (int64_t)ret_conv;
14322 }
14323
14324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14325         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14326         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14327         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
14328         return (int64_t)ret_conv;
14329 }
14330
14331 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14332         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
14333         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
14334         return ret_conv;
14335 }
14336
14337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14338         if ((_res & 1) != 0) return;
14339         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14340         CHECK_ACCESS(_res_ptr);
14341         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
14342         FREE((void*)_res);
14343         CResult_PublicKeyErrorZ_free(_res_conv);
14344 }
14345
14346 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
14347         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14348         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
14349         return (int64_t)ret_conv;
14350 }
14351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14352         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
14353         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
14354         return ret_conv;
14355 }
14356
14357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14358         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
14359         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
14360         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
14361         return (int64_t)ret_conv;
14362 }
14363
14364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14365         LDKTxCreationKeys o_conv;
14366         o_conv.inner = (void*)(o & (~1));
14367         o_conv.is_owned = (o & 1) || (o == 0);
14368         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14369         o_conv = TxCreationKeys_clone(&o_conv);
14370         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14371         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
14372         return (int64_t)ret_conv;
14373 }
14374
14375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14376         LDKDecodeError e_conv;
14377         e_conv.inner = (void*)(e & (~1));
14378         e_conv.is_owned = (e & 1) || (e == 0);
14379         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14380         e_conv = DecodeError_clone(&e_conv);
14381         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14382         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
14383         return (int64_t)ret_conv;
14384 }
14385
14386 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14387         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
14388         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
14389         return ret_conv;
14390 }
14391
14392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14393         if ((_res & 1) != 0) return;
14394         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14395         CHECK_ACCESS(_res_ptr);
14396         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
14397         FREE((void*)_res);
14398         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
14399 }
14400
14401 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
14402         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14403         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
14404         return (int64_t)ret_conv;
14405 }
14406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14407         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
14408         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
14409         return ret_conv;
14410 }
14411
14412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14413         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
14414         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
14415         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
14416         return (int64_t)ret_conv;
14417 }
14418
14419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14420         LDKChannelPublicKeys o_conv;
14421         o_conv.inner = (void*)(o & (~1));
14422         o_conv.is_owned = (o & 1) || (o == 0);
14423         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14424         o_conv = ChannelPublicKeys_clone(&o_conv);
14425         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14426         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
14427         return (int64_t)ret_conv;
14428 }
14429
14430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14431         LDKDecodeError e_conv;
14432         e_conv.inner = (void*)(e & (~1));
14433         e_conv.is_owned = (e & 1) || (e == 0);
14434         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14435         e_conv = DecodeError_clone(&e_conv);
14436         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14437         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
14438         return (int64_t)ret_conv;
14439 }
14440
14441 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14442         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
14443         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
14444         return ret_conv;
14445 }
14446
14447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14448         if ((_res & 1) != 0) return;
14449         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14450         CHECK_ACCESS(_res_ptr);
14451         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
14452         FREE((void*)_res);
14453         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
14454 }
14455
14456 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
14457         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14458         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
14459         return (int64_t)ret_conv;
14460 }
14461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14462         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
14463         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
14464         return ret_conv;
14465 }
14466
14467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14468         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
14469         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
14470         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
14471         return (int64_t)ret_conv;
14472 }
14473
14474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14475         LDKTxCreationKeys o_conv;
14476         o_conv.inner = (void*)(o & (~1));
14477         o_conv.is_owned = (o & 1) || (o == 0);
14478         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14479         o_conv = TxCreationKeys_clone(&o_conv);
14480         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14481         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
14482         return (int64_t)ret_conv;
14483 }
14484
14485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14486         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
14487         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14488         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
14489         return (int64_t)ret_conv;
14490 }
14491
14492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14493         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
14494         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
14495         return ret_conv;
14496 }
14497
14498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14499         if ((_res & 1) != 0) return;
14500         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14501         CHECK_ACCESS(_res_ptr);
14502         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
14503         FREE((void*)_res);
14504         CResult_TxCreationKeysErrorZ_free(_res_conv);
14505 }
14506
14507 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
14508         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14509         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
14510         return (int64_t)ret_conv;
14511 }
14512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14513         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
14514         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
14515         return ret_conv;
14516 }
14517
14518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14519         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
14520         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
14521         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
14522         return (int64_t)ret_conv;
14523 }
14524
14525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
14526         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14527         *ret_copy = COption_u32Z_some(o);
14528         int64_t ret_ref = (uintptr_t)ret_copy;
14529         return ret_ref;
14530 }
14531
14532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
14533         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14534         *ret_copy = COption_u32Z_none();
14535         int64_t ret_ref = (uintptr_t)ret_copy;
14536         return ret_ref;
14537 }
14538
14539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14540         if ((_res & 1) != 0) return;
14541         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14542         CHECK_ACCESS(_res_ptr);
14543         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
14544         FREE((void*)_res);
14545         COption_u32Z_free(_res_conv);
14546 }
14547
14548 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
14549         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14550         *ret_copy = COption_u32Z_clone(arg);
14551 int64_t ret_ref = (uintptr_t)ret_copy;
14552         return ret_ref;
14553 }
14554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14555         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
14556         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
14557         return ret_conv;
14558 }
14559
14560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14561         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
14562         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
14563         *ret_copy = COption_u32Z_clone(orig_conv);
14564         int64_t ret_ref = (uintptr_t)ret_copy;
14565         return ret_ref;
14566 }
14567
14568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14569         LDKHTLCOutputInCommitment o_conv;
14570         o_conv.inner = (void*)(o & (~1));
14571         o_conv.is_owned = (o & 1) || (o == 0);
14572         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14573         o_conv = HTLCOutputInCommitment_clone(&o_conv);
14574         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14575         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
14576         return (int64_t)ret_conv;
14577 }
14578
14579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14580         LDKDecodeError e_conv;
14581         e_conv.inner = (void*)(e & (~1));
14582         e_conv.is_owned = (e & 1) || (e == 0);
14583         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14584         e_conv = DecodeError_clone(&e_conv);
14585         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14586         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
14587         return (int64_t)ret_conv;
14588 }
14589
14590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14591         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
14592         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
14593         return ret_conv;
14594 }
14595
14596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14597         if ((_res & 1) != 0) return;
14598         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14599         CHECK_ACCESS(_res_ptr);
14600         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
14601         FREE((void*)_res);
14602         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
14603 }
14604
14605 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
14606         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14607         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
14608         return (int64_t)ret_conv;
14609 }
14610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14611         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
14612         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
14613         return ret_conv;
14614 }
14615
14616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14617         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
14618         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
14619         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
14620         return (int64_t)ret_conv;
14621 }
14622
14623 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
14624         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
14625         return ret_conv;
14626 }
14627
14628 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
14629         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
14630         return ret_conv;
14631 }
14632
14633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
14634         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
14635         COption_NoneZ_free(_res_conv);
14636 }
14637
14638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14639         LDKCounterpartyChannelTransactionParameters o_conv;
14640         o_conv.inner = (void*)(o & (~1));
14641         o_conv.is_owned = (o & 1) || (o == 0);
14642         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14643         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
14644         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14645         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14646         return (int64_t)ret_conv;
14647 }
14648
14649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14650         LDKDecodeError e_conv;
14651         e_conv.inner = (void*)(e & (~1));
14652         e_conv.is_owned = (e & 1) || (e == 0);
14653         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14654         e_conv = DecodeError_clone(&e_conv);
14655         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14656         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
14657         return (int64_t)ret_conv;
14658 }
14659
14660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14661         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
14662         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14663         return ret_conv;
14664 }
14665
14666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14667         if ((_res & 1) != 0) return;
14668         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14669         CHECK_ACCESS(_res_ptr);
14670         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14671         FREE((void*)_res);
14672         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14673 }
14674
14675 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14676         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14677         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
14678         return (int64_t)ret_conv;
14679 }
14680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14681         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
14682         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14683         return ret_conv;
14684 }
14685
14686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14687         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
14688         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
14689         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14690         return (int64_t)ret_conv;
14691 }
14692
14693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14694         LDKChannelTransactionParameters o_conv;
14695         o_conv.inner = (void*)(o & (~1));
14696         o_conv.is_owned = (o & 1) || (o == 0);
14697         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14698         o_conv = ChannelTransactionParameters_clone(&o_conv);
14699         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14700         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
14701         return (int64_t)ret_conv;
14702 }
14703
14704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14705         LDKDecodeError e_conv;
14706         e_conv.inner = (void*)(e & (~1));
14707         e_conv.is_owned = (e & 1) || (e == 0);
14708         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14709         e_conv = DecodeError_clone(&e_conv);
14710         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14711         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
14712         return (int64_t)ret_conv;
14713 }
14714
14715 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14716         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
14717         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
14718         return ret_conv;
14719 }
14720
14721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14722         if ((_res & 1) != 0) return;
14723         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14724         CHECK_ACCESS(_res_ptr);
14725         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
14726         FREE((void*)_res);
14727         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
14728 }
14729
14730 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
14731         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14732         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
14733         return (int64_t)ret_conv;
14734 }
14735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14736         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
14737         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
14738         return ret_conv;
14739 }
14740
14741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14742         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
14743         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
14744         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
14745         return (int64_t)ret_conv;
14746 }
14747
14748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
14749         LDKCVec_SignatureZ _res_constr;
14750         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14751         if (_res_constr.datalen > 0)
14752                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14753         else
14754                 _res_constr.data = NULL;
14755         for (size_t i = 0; i < _res_constr.datalen; i++) {
14756                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
14757                 LDKSignature _res_conv_8_ref;
14758                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
14759                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
14760                 _res_constr.data[i] = _res_conv_8_ref;
14761         }
14762         CVec_SignatureZ_free(_res_constr);
14763 }
14764
14765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14766         LDKHolderCommitmentTransaction o_conv;
14767         o_conv.inner = (void*)(o & (~1));
14768         o_conv.is_owned = (o & 1) || (o == 0);
14769         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14770         o_conv = HolderCommitmentTransaction_clone(&o_conv);
14771         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14772         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
14773         return (int64_t)ret_conv;
14774 }
14775
14776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14777         LDKDecodeError e_conv;
14778         e_conv.inner = (void*)(e & (~1));
14779         e_conv.is_owned = (e & 1) || (e == 0);
14780         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14781         e_conv = DecodeError_clone(&e_conv);
14782         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14783         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
14784         return (int64_t)ret_conv;
14785 }
14786
14787 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14788         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
14789         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14790         return ret_conv;
14791 }
14792
14793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14794         if ((_res & 1) != 0) return;
14795         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14796         CHECK_ACCESS(_res_ptr);
14797         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14798         FREE((void*)_res);
14799         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
14800 }
14801
14802 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14803         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14804         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
14805         return (int64_t)ret_conv;
14806 }
14807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14808         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
14809         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14810         return ret_conv;
14811 }
14812
14813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14814         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
14815         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
14816         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14817         return (int64_t)ret_conv;
14818 }
14819
14820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14821         LDKBuiltCommitmentTransaction o_conv;
14822         o_conv.inner = (void*)(o & (~1));
14823         o_conv.is_owned = (o & 1) || (o == 0);
14824         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14825         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
14826         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14827         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
14828         return (int64_t)ret_conv;
14829 }
14830
14831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14832         LDKDecodeError e_conv;
14833         e_conv.inner = (void*)(e & (~1));
14834         e_conv.is_owned = (e & 1) || (e == 0);
14835         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14836         e_conv = DecodeError_clone(&e_conv);
14837         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14838         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
14839         return (int64_t)ret_conv;
14840 }
14841
14842 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14843         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
14844         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14845         return ret_conv;
14846 }
14847
14848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14849         if ((_res & 1) != 0) return;
14850         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14851         CHECK_ACCESS(_res_ptr);
14852         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
14853         FREE((void*)_res);
14854         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
14855 }
14856
14857 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14858         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14859         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
14860         return (int64_t)ret_conv;
14861 }
14862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14863         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
14864         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14865         return ret_conv;
14866 }
14867
14868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14869         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
14870         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
14871         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
14872         return (int64_t)ret_conv;
14873 }
14874
14875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14876         LDKTrustedClosingTransaction o_conv;
14877         o_conv.inner = (void*)(o & (~1));
14878         o_conv.is_owned = (o & 1) || (o == 0);
14879         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14880         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
14881         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14882         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
14883         return (int64_t)ret_conv;
14884 }
14885
14886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14887         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
14888         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
14889         return (int64_t)ret_conv;
14890 }
14891
14892 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14893         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
14894         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
14895         return ret_conv;
14896 }
14897
14898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14899         if ((_res & 1) != 0) return;
14900         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14901         CHECK_ACCESS(_res_ptr);
14902         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
14903         FREE((void*)_res);
14904         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
14905 }
14906
14907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14908         LDKCommitmentTransaction o_conv;
14909         o_conv.inner = (void*)(o & (~1));
14910         o_conv.is_owned = (o & 1) || (o == 0);
14911         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14912         o_conv = CommitmentTransaction_clone(&o_conv);
14913         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14914         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
14915         return (int64_t)ret_conv;
14916 }
14917
14918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14919         LDKDecodeError e_conv;
14920         e_conv.inner = (void*)(e & (~1));
14921         e_conv.is_owned = (e & 1) || (e == 0);
14922         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14923         e_conv = DecodeError_clone(&e_conv);
14924         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14925         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
14926         return (int64_t)ret_conv;
14927 }
14928
14929 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14930         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
14931         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
14932         return ret_conv;
14933 }
14934
14935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14936         if ((_res & 1) != 0) return;
14937         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14938         CHECK_ACCESS(_res_ptr);
14939         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
14940         FREE((void*)_res);
14941         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
14942 }
14943
14944 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
14945         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14946         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
14947         return (int64_t)ret_conv;
14948 }
14949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14950         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
14951         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
14952         return ret_conv;
14953 }
14954
14955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14956         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
14957         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
14958         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
14959         return (int64_t)ret_conv;
14960 }
14961
14962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14963         LDKTrustedCommitmentTransaction o_conv;
14964         o_conv.inner = (void*)(o & (~1));
14965         o_conv.is_owned = (o & 1) || (o == 0);
14966         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14967         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
14968         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14969         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
14970         return (int64_t)ret_conv;
14971 }
14972
14973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
14974         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14975         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
14976         return (int64_t)ret_conv;
14977 }
14978
14979 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14980         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
14981         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
14982         return ret_conv;
14983 }
14984
14985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14986         if ((_res & 1) != 0) return;
14987         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14988         CHECK_ACCESS(_res_ptr);
14989         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
14990         FREE((void*)_res);
14991         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
14992 }
14993
14994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
14995         LDKCVec_SignatureZ o_constr;
14996         o_constr.datalen = (*env)->GetArrayLength(env, o);
14997         if (o_constr.datalen > 0)
14998                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14999         else
15000                 o_constr.data = NULL;
15001         for (size_t i = 0; i < o_constr.datalen; i++) {
15002                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
15003                 LDKSignature o_conv_8_ref;
15004                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
15005                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
15006                 o_constr.data[i] = o_conv_8_ref;
15007         }
15008         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15009         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
15010         return (int64_t)ret_conv;
15011 }
15012
15013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
15014         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15015         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
15016         return (int64_t)ret_conv;
15017 }
15018
15019 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15020         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
15021         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
15022         return ret_conv;
15023 }
15024
15025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15026         if ((_res & 1) != 0) return;
15027         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15028         CHECK_ACCESS(_res_ptr);
15029         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
15030         FREE((void*)_res);
15031         CResult_CVec_SignatureZNoneZ_free(_res_conv);
15032 }
15033
15034 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
15035         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15036         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
15037         return (int64_t)ret_conv;
15038 }
15039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15040         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
15041         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
15042         return ret_conv;
15043 }
15044
15045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15046         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
15047         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
15048         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
15049         return (int64_t)ret_conv;
15050 }
15051
15052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15053         LDKShutdownScript o_conv;
15054         o_conv.inner = (void*)(o & (~1));
15055         o_conv.is_owned = (o & 1) || (o == 0);
15056         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15057         o_conv = ShutdownScript_clone(&o_conv);
15058         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15059         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
15060         return (int64_t)ret_conv;
15061 }
15062
15063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15064         LDKDecodeError e_conv;
15065         e_conv.inner = (void*)(e & (~1));
15066         e_conv.is_owned = (e & 1) || (e == 0);
15067         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15068         e_conv = DecodeError_clone(&e_conv);
15069         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15070         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
15071         return (int64_t)ret_conv;
15072 }
15073
15074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15075         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
15076         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
15077         return ret_conv;
15078 }
15079
15080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15081         if ((_res & 1) != 0) return;
15082         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15083         CHECK_ACCESS(_res_ptr);
15084         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
15085         FREE((void*)_res);
15086         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
15087 }
15088
15089 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
15090         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15091         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
15092         return (int64_t)ret_conv;
15093 }
15094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15095         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
15096         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
15097         return ret_conv;
15098 }
15099
15100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15101         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
15102         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
15103         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
15104         return (int64_t)ret_conv;
15105 }
15106
15107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15108         LDKShutdownScript o_conv;
15109         o_conv.inner = (void*)(o & (~1));
15110         o_conv.is_owned = (o & 1) || (o == 0);
15111         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15112         o_conv = ShutdownScript_clone(&o_conv);
15113         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15114         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
15115         return (int64_t)ret_conv;
15116 }
15117
15118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15119         LDKInvalidShutdownScript e_conv;
15120         e_conv.inner = (void*)(e & (~1));
15121         e_conv.is_owned = (e & 1) || (e == 0);
15122         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15123         e_conv = InvalidShutdownScript_clone(&e_conv);
15124         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15125         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
15126         return (int64_t)ret_conv;
15127 }
15128
15129 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15130         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
15131         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
15132         return ret_conv;
15133 }
15134
15135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15136         if ((_res & 1) != 0) return;
15137         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15138         CHECK_ACCESS(_res_ptr);
15139         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
15140         FREE((void*)_res);
15141         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
15142 }
15143
15144 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
15145         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15146         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
15147         return (int64_t)ret_conv;
15148 }
15149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15150         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
15151         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
15152         return ret_conv;
15153 }
15154
15155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15156         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
15157         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
15158         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
15159         return (int64_t)ret_conv;
15160 }
15161
15162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
15163         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15164         *ret_conv = CResult_NoneErrorZ_ok();
15165         return (int64_t)ret_conv;
15166 }
15167
15168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15169         LDKIOError e_conv = LDKIOError_from_java(env, e);
15170         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15171         *ret_conv = CResult_NoneErrorZ_err(e_conv);
15172         return (int64_t)ret_conv;
15173 }
15174
15175 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15176         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
15177         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
15178         return ret_conv;
15179 }
15180
15181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15182         if ((_res & 1) != 0) return;
15183         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15184         CHECK_ACCESS(_res_ptr);
15185         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
15186         FREE((void*)_res);
15187         CResult_NoneErrorZ_free(_res_conv);
15188 }
15189
15190 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
15191         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15192         *ret_conv = CResult_NoneErrorZ_clone(arg);
15193         return (int64_t)ret_conv;
15194 }
15195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15196         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
15197         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
15198         return ret_conv;
15199 }
15200
15201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15202         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
15203         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
15204         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
15205         return (int64_t)ret_conv;
15206 }
15207
15208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15209         LDKRouteHop o_conv;
15210         o_conv.inner = (void*)(o & (~1));
15211         o_conv.is_owned = (o & 1) || (o == 0);
15212         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15213         o_conv = RouteHop_clone(&o_conv);
15214         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15215         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
15216         return (int64_t)ret_conv;
15217 }
15218
15219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15220         LDKDecodeError e_conv;
15221         e_conv.inner = (void*)(e & (~1));
15222         e_conv.is_owned = (e & 1) || (e == 0);
15223         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15224         e_conv = DecodeError_clone(&e_conv);
15225         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15226         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
15227         return (int64_t)ret_conv;
15228 }
15229
15230 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15231         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
15232         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
15233         return ret_conv;
15234 }
15235
15236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15237         if ((_res & 1) != 0) return;
15238         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15239         CHECK_ACCESS(_res_ptr);
15240         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
15241         FREE((void*)_res);
15242         CResult_RouteHopDecodeErrorZ_free(_res_conv);
15243 }
15244
15245 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
15246         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15247         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
15248         return (int64_t)ret_conv;
15249 }
15250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15251         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
15252         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
15253         return ret_conv;
15254 }
15255
15256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15257         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
15258         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
15259         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
15260         return (int64_t)ret_conv;
15261 }
15262
15263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15264         LDKCVec_RouteHopZ _res_constr;
15265         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15266         if (_res_constr.datalen > 0)
15267                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15268         else
15269                 _res_constr.data = NULL;
15270         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15271         for (size_t k = 0; k < _res_constr.datalen; k++) {
15272                 int64_t _res_conv_10 = _res_vals[k];
15273                 LDKRouteHop _res_conv_10_conv;
15274                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15275                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15276                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
15277                 _res_constr.data[k] = _res_conv_10_conv;
15278         }
15279         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15280         CVec_RouteHopZ_free(_res_constr);
15281 }
15282
15283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15284         LDKCVec_CVec_RouteHopZZ _res_constr;
15285         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15286         if (_res_constr.datalen > 0)
15287                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
15288         else
15289                 _res_constr.data = NULL;
15290         for (size_t m = 0; m < _res_constr.datalen; m++) {
15291                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
15292                 LDKCVec_RouteHopZ _res_conv_12_constr;
15293                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
15294                 if (_res_conv_12_constr.datalen > 0)
15295                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15296                 else
15297                         _res_conv_12_constr.data = NULL;
15298                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
15299                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
15300                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
15301                         LDKRouteHop _res_conv_12_conv_10_conv;
15302                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
15303                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
15304                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
15305                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
15306                 }
15307                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
15308                 _res_constr.data[m] = _res_conv_12_constr;
15309         }
15310         CVec_CVec_RouteHopZZ_free(_res_constr);
15311 }
15312
15313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15314         LDKRoute o_conv;
15315         o_conv.inner = (void*)(o & (~1));
15316         o_conv.is_owned = (o & 1) || (o == 0);
15317         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15318         o_conv = Route_clone(&o_conv);
15319         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15320         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
15321         return (int64_t)ret_conv;
15322 }
15323
15324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15325         LDKDecodeError e_conv;
15326         e_conv.inner = (void*)(e & (~1));
15327         e_conv.is_owned = (e & 1) || (e == 0);
15328         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15329         e_conv = DecodeError_clone(&e_conv);
15330         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15331         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
15332         return (int64_t)ret_conv;
15333 }
15334
15335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15336         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
15337         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
15338         return ret_conv;
15339 }
15340
15341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15342         if ((_res & 1) != 0) return;
15343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15344         CHECK_ACCESS(_res_ptr);
15345         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
15346         FREE((void*)_res);
15347         CResult_RouteDecodeErrorZ_free(_res_conv);
15348 }
15349
15350 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
15351         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15352         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
15353         return (int64_t)ret_conv;
15354 }
15355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15356         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
15357         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
15358         return ret_conv;
15359 }
15360
15361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15362         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
15363         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
15364         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
15365         return (int64_t)ret_conv;
15366 }
15367
15368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15369         LDKRouteParameters o_conv;
15370         o_conv.inner = (void*)(o & (~1));
15371         o_conv.is_owned = (o & 1) || (o == 0);
15372         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15373         o_conv = RouteParameters_clone(&o_conv);
15374         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15375         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
15376         return (int64_t)ret_conv;
15377 }
15378
15379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15380         LDKDecodeError e_conv;
15381         e_conv.inner = (void*)(e & (~1));
15382         e_conv.is_owned = (e & 1) || (e == 0);
15383         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15384         e_conv = DecodeError_clone(&e_conv);
15385         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15386         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
15387         return (int64_t)ret_conv;
15388 }
15389
15390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15391         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
15392         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
15393         return ret_conv;
15394 }
15395
15396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15397         if ((_res & 1) != 0) return;
15398         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15399         CHECK_ACCESS(_res_ptr);
15400         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
15401         FREE((void*)_res);
15402         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
15403 }
15404
15405 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
15406         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15407         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
15408         return (int64_t)ret_conv;
15409 }
15410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15411         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
15412         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
15413         return ret_conv;
15414 }
15415
15416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15417         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
15418         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
15419         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
15420         return (int64_t)ret_conv;
15421 }
15422
15423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15424         LDKCVec_RouteHintZ _res_constr;
15425         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15426         if (_res_constr.datalen > 0)
15427                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
15428         else
15429                 _res_constr.data = NULL;
15430         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15431         for (size_t l = 0; l < _res_constr.datalen; l++) {
15432                 int64_t _res_conv_11 = _res_vals[l];
15433                 LDKRouteHint _res_conv_11_conv;
15434                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
15435                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
15436                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
15437                 _res_constr.data[l] = _res_conv_11_conv;
15438         }
15439         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15440         CVec_RouteHintZ_free(_res_constr);
15441 }
15442
15443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
15444         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15445         *ret_copy = COption_u64Z_some(o);
15446         int64_t ret_ref = (uintptr_t)ret_copy;
15447         return ret_ref;
15448 }
15449
15450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
15451         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15452         *ret_copy = COption_u64Z_none();
15453         int64_t ret_ref = (uintptr_t)ret_copy;
15454         return ret_ref;
15455 }
15456
15457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15458         if ((_res & 1) != 0) return;
15459         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15460         CHECK_ACCESS(_res_ptr);
15461         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
15462         FREE((void*)_res);
15463         COption_u64Z_free(_res_conv);
15464 }
15465
15466 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
15467         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15468         *ret_copy = COption_u64Z_clone(arg);
15469 int64_t ret_ref = (uintptr_t)ret_copy;
15470         return ret_ref;
15471 }
15472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15473         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
15474         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
15475         return ret_conv;
15476 }
15477
15478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15479         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
15480         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15481         *ret_copy = COption_u64Z_clone(orig_conv);
15482         int64_t ret_ref = (uintptr_t)ret_copy;
15483         return ret_ref;
15484 }
15485
15486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15487         LDKPaymentParameters o_conv;
15488         o_conv.inner = (void*)(o & (~1));
15489         o_conv.is_owned = (o & 1) || (o == 0);
15490         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15491         o_conv = PaymentParameters_clone(&o_conv);
15492         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15493         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
15494         return (int64_t)ret_conv;
15495 }
15496
15497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15498         LDKDecodeError e_conv;
15499         e_conv.inner = (void*)(e & (~1));
15500         e_conv.is_owned = (e & 1) || (e == 0);
15501         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15502         e_conv = DecodeError_clone(&e_conv);
15503         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15504         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
15505         return (int64_t)ret_conv;
15506 }
15507
15508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15509         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
15510         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
15511         return ret_conv;
15512 }
15513
15514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15515         if ((_res & 1) != 0) return;
15516         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15517         CHECK_ACCESS(_res_ptr);
15518         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
15519         FREE((void*)_res);
15520         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
15521 }
15522
15523 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
15524         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15525         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
15526         return (int64_t)ret_conv;
15527 }
15528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15529         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
15530         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
15531         return ret_conv;
15532 }
15533
15534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15535         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
15536         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
15537         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
15538         return (int64_t)ret_conv;
15539 }
15540
15541 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15542         LDKCVec_RouteHintHopZ _res_constr;
15543         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15544         if (_res_constr.datalen > 0)
15545                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
15546         else
15547                 _res_constr.data = NULL;
15548         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15549         for (size_t o = 0; o < _res_constr.datalen; o++) {
15550                 int64_t _res_conv_14 = _res_vals[o];
15551                 LDKRouteHintHop _res_conv_14_conv;
15552                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15553                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15554                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15555                 _res_constr.data[o] = _res_conv_14_conv;
15556         }
15557         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15558         CVec_RouteHintHopZ_free(_res_constr);
15559 }
15560
15561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15562         LDKRouteHint o_conv;
15563         o_conv.inner = (void*)(o & (~1));
15564         o_conv.is_owned = (o & 1) || (o == 0);
15565         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15566         o_conv = RouteHint_clone(&o_conv);
15567         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15568         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
15569         return (int64_t)ret_conv;
15570 }
15571
15572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15573         LDKDecodeError e_conv;
15574         e_conv.inner = (void*)(e & (~1));
15575         e_conv.is_owned = (e & 1) || (e == 0);
15576         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15577         e_conv = DecodeError_clone(&e_conv);
15578         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15579         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
15580         return (int64_t)ret_conv;
15581 }
15582
15583 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15584         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
15585         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
15586         return ret_conv;
15587 }
15588
15589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15590         if ((_res & 1) != 0) return;
15591         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15592         CHECK_ACCESS(_res_ptr);
15593         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
15594         FREE((void*)_res);
15595         CResult_RouteHintDecodeErrorZ_free(_res_conv);
15596 }
15597
15598 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
15599         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15600         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
15601         return (int64_t)ret_conv;
15602 }
15603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15604         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
15605         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
15606         return ret_conv;
15607 }
15608
15609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15610         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
15611         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
15612         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
15613         return (int64_t)ret_conv;
15614 }
15615
15616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15617         LDKRouteHintHop o_conv;
15618         o_conv.inner = (void*)(o & (~1));
15619         o_conv.is_owned = (o & 1) || (o == 0);
15620         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15621         o_conv = RouteHintHop_clone(&o_conv);
15622         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15623         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
15624         return (int64_t)ret_conv;
15625 }
15626
15627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15628         LDKDecodeError e_conv;
15629         e_conv.inner = (void*)(e & (~1));
15630         e_conv.is_owned = (e & 1) || (e == 0);
15631         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15632         e_conv = DecodeError_clone(&e_conv);
15633         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15634         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
15635         return (int64_t)ret_conv;
15636 }
15637
15638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15639         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
15640         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
15641         return ret_conv;
15642 }
15643
15644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15645         if ((_res & 1) != 0) return;
15646         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15647         CHECK_ACCESS(_res_ptr);
15648         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
15649         FREE((void*)_res);
15650         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
15651 }
15652
15653 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
15654         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15655         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
15656         return (int64_t)ret_conv;
15657 }
15658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15659         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
15660         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
15661         return ret_conv;
15662 }
15663
15664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15665         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
15666         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
15667         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
15668         return (int64_t)ret_conv;
15669 }
15670
15671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15672         LDKCVec_ChannelDetailsZ _res_constr;
15673         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15674         if (_res_constr.datalen > 0)
15675                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15676         else
15677                 _res_constr.data = NULL;
15678         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15679         for (size_t q = 0; q < _res_constr.datalen; q++) {
15680                 int64_t _res_conv_16 = _res_vals[q];
15681                 LDKChannelDetails _res_conv_16_conv;
15682                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
15683                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
15684                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
15685                 _res_constr.data[q] = _res_conv_16_conv;
15686         }
15687         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15688         CVec_ChannelDetailsZ_free(_res_constr);
15689 }
15690
15691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15692         LDKRoute o_conv;
15693         o_conv.inner = (void*)(o & (~1));
15694         o_conv.is_owned = (o & 1) || (o == 0);
15695         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15696         o_conv = Route_clone(&o_conv);
15697         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15698         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
15699         return (int64_t)ret_conv;
15700 }
15701
15702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15703         LDKLightningError e_conv;
15704         e_conv.inner = (void*)(e & (~1));
15705         e_conv.is_owned = (e & 1) || (e == 0);
15706         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15707         e_conv = LightningError_clone(&e_conv);
15708         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15709         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
15710         return (int64_t)ret_conv;
15711 }
15712
15713 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15714         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
15715         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
15716         return ret_conv;
15717 }
15718
15719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15720         if ((_res & 1) != 0) return;
15721         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15722         CHECK_ACCESS(_res_ptr);
15723         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
15724         FREE((void*)_res);
15725         CResult_RouteLightningErrorZ_free(_res_conv);
15726 }
15727
15728 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
15729         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15730         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
15731         return (int64_t)ret_conv;
15732 }
15733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15734         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
15735         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
15736         return ret_conv;
15737 }
15738
15739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15740         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
15741         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15742         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
15743         return (int64_t)ret_conv;
15744 }
15745
15746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15747         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15748         CHECK_ACCESS(o_ptr);
15749         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
15750         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
15751         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15752         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
15753         return (int64_t)ret_conv;
15754 }
15755
15756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15757         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
15758         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15759         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
15760         return (int64_t)ret_conv;
15761 }
15762
15763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15764         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
15765         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
15766         return ret_conv;
15767 }
15768
15769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15770         if ((_res & 1) != 0) return;
15771         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15772         CHECK_ACCESS(_res_ptr);
15773         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
15774         FREE((void*)_res);
15775         CResult_TxOutAccessErrorZ_free(_res_conv);
15776 }
15777
15778 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
15779         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15780         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
15781         return (int64_t)ret_conv;
15782 }
15783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15784         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
15785         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
15786         return ret_conv;
15787 }
15788
15789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15790         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
15791         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
15792         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
15793         return (int64_t)ret_conv;
15794 }
15795
15796 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
15797         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15798         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
15799         return ((int64_t)ret_conv);
15800 }
15801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15802         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
15803         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
15804         return ret_conv;
15805 }
15806
15807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15808         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
15809         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15810         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
15811         return ((int64_t)ret_conv);
15812 }
15813
15814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
15815         LDKTransaction b_ref;
15816         b_ref.datalen = (*env)->GetArrayLength(env, b);
15817         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
15818         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
15819         b_ref.data_is_owned = true;
15820         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
15821         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
15822         return ((int64_t)ret_conv);
15823 }
15824
15825 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15826         if ((_res & 1) != 0) return;
15827         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15828         CHECK_ACCESS(_res_ptr);
15829         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
15830         FREE((void*)_res);
15831         C2Tuple_usizeTransactionZ_free(_res_conv);
15832 }
15833
15834 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15835         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
15836         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15837         if (_res_constr.datalen > 0)
15838                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
15839         else
15840                 _res_constr.data = NULL;
15841         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15842         for (size_t c = 0; c < _res_constr.datalen; c++) {
15843                 int64_t _res_conv_28 = _res_vals[c];
15844                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
15845                 CHECK_ACCESS(_res_conv_28_ptr);
15846                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
15847                 FREE((void*)_res_conv_28);
15848                 _res_constr.data[c] = _res_conv_28_conv;
15849         }
15850         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15851         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
15852 }
15853
15854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15855         LDKCVec_TxidZ _res_constr;
15856         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15857         if (_res_constr.datalen > 0)
15858                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
15859         else
15860                 _res_constr.data = NULL;
15861         for (size_t i = 0; i < _res_constr.datalen; i++) {
15862                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15863                 LDKThirtyTwoBytes _res_conv_8_ref;
15864                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
15865                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
15866                 _res_constr.data[i] = _res_conv_8_ref;
15867         }
15868         CVec_TxidZ_free(_res_constr);
15869 }
15870
15871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
15872         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15873         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
15874         return (int64_t)ret_conv;
15875 }
15876
15877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
15878         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
15879         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15880         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
15881         return (int64_t)ret_conv;
15882 }
15883
15884 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15885         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
15886         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
15887         return ret_conv;
15888 }
15889
15890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15891         if ((_res & 1) != 0) return;
15892         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15893         CHECK_ACCESS(_res_ptr);
15894         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
15895         FREE((void*)_res);
15896         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
15897 }
15898
15899 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
15900         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15901         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
15902         return (int64_t)ret_conv;
15903 }
15904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15905         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
15906         int64_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
15907         return ret_conv;
15908 }
15909
15910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15911         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
15912         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
15913         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
15914         return (int64_t)ret_conv;
15915 }
15916
15917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15918         LDKCVec_MonitorEventZ _res_constr;
15919         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15920         if (_res_constr.datalen > 0)
15921                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
15922         else
15923                 _res_constr.data = NULL;
15924         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15925         for (size_t o = 0; o < _res_constr.datalen; o++) {
15926                 int64_t _res_conv_14 = _res_vals[o];
15927                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
15928                 CHECK_ACCESS(_res_conv_14_ptr);
15929                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
15930                 FREE((void*)_res_conv_14);
15931                 _res_constr.data[o] = _res_conv_14_conv;
15932         }
15933         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15934         CVec_MonitorEventZ_free(_res_constr);
15935 }
15936
15937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15938         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15939         CHECK_ACCESS(o_ptr);
15940         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
15941         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
15942         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15943         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
15944         int64_t ret_ref = (uintptr_t)ret_copy;
15945         return ret_ref;
15946 }
15947
15948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
15949         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15950         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
15951         int64_t ret_ref = (uintptr_t)ret_copy;
15952         return ret_ref;
15953 }
15954
15955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15956         if ((_res & 1) != 0) return;
15957         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15958         CHECK_ACCESS(_res_ptr);
15959         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
15960         FREE((void*)_res);
15961         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
15962 }
15963
15964 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
15965         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15966         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
15967 int64_t ret_ref = (uintptr_t)ret_copy;
15968         return ret_ref;
15969 }
15970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15971         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
15972         int64_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
15973         return ret_conv;
15974 }
15975
15976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15977         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
15978         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
15979         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
15980         int64_t ret_ref = (uintptr_t)ret_copy;
15981         return ret_ref;
15982 }
15983
15984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15985         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15986         CHECK_ACCESS(o_ptr);
15987         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
15988         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
15989         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15990         *ret_copy = COption_ClosureReasonZ_some(o_conv);
15991         int64_t ret_ref = (uintptr_t)ret_copy;
15992         return ret_ref;
15993 }
15994
15995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
15996         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
15997         *ret_copy = COption_ClosureReasonZ_none();
15998         int64_t ret_ref = (uintptr_t)ret_copy;
15999         return ret_ref;
16000 }
16001
16002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16003         if ((_res & 1) != 0) return;
16004         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16005         CHECK_ACCESS(_res_ptr);
16006         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
16007         FREE((void*)_res);
16008         COption_ClosureReasonZ_free(_res_conv);
16009 }
16010
16011 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
16012         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16013         *ret_copy = COption_ClosureReasonZ_clone(arg);
16014 int64_t ret_ref = (uintptr_t)ret_copy;
16015         return ret_ref;
16016 }
16017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16018         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
16019         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
16020         return ret_conv;
16021 }
16022
16023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16024         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
16025         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16026         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
16027         int64_t ret_ref = (uintptr_t)ret_copy;
16028         return ret_ref;
16029 }
16030
16031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16032         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16033         CHECK_ACCESS(o_ptr);
16034         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
16035         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
16036         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16037         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
16038         return (int64_t)ret_conv;
16039 }
16040
16041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16042         LDKDecodeError e_conv;
16043         e_conv.inner = (void*)(e & (~1));
16044         e_conv.is_owned = (e & 1) || (e == 0);
16045         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16046         e_conv = DecodeError_clone(&e_conv);
16047         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16048         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
16049         return (int64_t)ret_conv;
16050 }
16051
16052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16053         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
16054         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
16055         return ret_conv;
16056 }
16057
16058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16059         if ((_res & 1) != 0) return;
16060         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16061         CHECK_ACCESS(_res_ptr);
16062         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
16063         FREE((void*)_res);
16064         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
16065 }
16066
16067 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
16068         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16069         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
16070         return (int64_t)ret_conv;
16071 }
16072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16073         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
16074         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
16075         return ret_conv;
16076 }
16077
16078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16079         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
16080         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16081         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
16082         return (int64_t)ret_conv;
16083 }
16084
16085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16086         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16087         CHECK_ACCESS(o_ptr);
16088         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
16089         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
16090         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16091         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
16092         int64_t ret_ref = (uintptr_t)ret_copy;
16093         return ret_ref;
16094 }
16095
16096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
16097         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16098         *ret_copy = COption_NetworkUpdateZ_none();
16099         int64_t ret_ref = (uintptr_t)ret_copy;
16100         return ret_ref;
16101 }
16102
16103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16104         if ((_res & 1) != 0) return;
16105         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16106         CHECK_ACCESS(_res_ptr);
16107         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
16108         FREE((void*)_res);
16109         COption_NetworkUpdateZ_free(_res_conv);
16110 }
16111
16112 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
16113         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16114         *ret_copy = COption_NetworkUpdateZ_clone(arg);
16115 int64_t ret_ref = (uintptr_t)ret_copy;
16116         return ret_ref;
16117 }
16118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16119         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
16120         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
16121         return ret_conv;
16122 }
16123
16124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16125         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
16126         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
16127         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
16128         int64_t ret_ref = (uintptr_t)ret_copy;
16129         return ret_ref;
16130 }
16131
16132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16133         LDKCVec_SpendableOutputDescriptorZ _res_constr;
16134         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16135         if (_res_constr.datalen > 0)
16136                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16137         else
16138                 _res_constr.data = NULL;
16139         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16140         for (size_t b = 0; b < _res_constr.datalen; b++) {
16141                 int64_t _res_conv_27 = _res_vals[b];
16142                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
16143                 CHECK_ACCESS(_res_conv_27_ptr);
16144                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
16145                 FREE((void*)_res_conv_27);
16146                 _res_constr.data[b] = _res_conv_27_conv;
16147         }
16148         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16149         CVec_SpendableOutputDescriptorZ_free(_res_constr);
16150 }
16151
16152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16153         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16154         CHECK_ACCESS(o_ptr);
16155         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
16156         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
16157         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16158         *ret_copy = COption_EventZ_some(o_conv);
16159         int64_t ret_ref = (uintptr_t)ret_copy;
16160         return ret_ref;
16161 }
16162
16163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
16164         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16165         *ret_copy = COption_EventZ_none();
16166         int64_t ret_ref = (uintptr_t)ret_copy;
16167         return ret_ref;
16168 }
16169
16170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16171         if ((_res & 1) != 0) return;
16172         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16173         CHECK_ACCESS(_res_ptr);
16174         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
16175         FREE((void*)_res);
16176         COption_EventZ_free(_res_conv);
16177 }
16178
16179 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
16180         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16181         *ret_copy = COption_EventZ_clone(arg);
16182 int64_t ret_ref = (uintptr_t)ret_copy;
16183         return ret_ref;
16184 }
16185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16186         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
16187         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
16188         return ret_conv;
16189 }
16190
16191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16192         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
16193         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
16194         *ret_copy = COption_EventZ_clone(orig_conv);
16195         int64_t ret_ref = (uintptr_t)ret_copy;
16196         return ret_ref;
16197 }
16198
16199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16200         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16201         CHECK_ACCESS(o_ptr);
16202         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
16203         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
16204         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16205         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
16206         return (int64_t)ret_conv;
16207 }
16208
16209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16210         LDKDecodeError e_conv;
16211         e_conv.inner = (void*)(e & (~1));
16212         e_conv.is_owned = (e & 1) || (e == 0);
16213         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16214         e_conv = DecodeError_clone(&e_conv);
16215         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16216         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
16217         return (int64_t)ret_conv;
16218 }
16219
16220 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16221         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
16222         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
16223         return ret_conv;
16224 }
16225
16226 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16227         if ((_res & 1) != 0) return;
16228         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16229         CHECK_ACCESS(_res_ptr);
16230         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
16231         FREE((void*)_res);
16232         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
16233 }
16234
16235 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
16236         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16237         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
16238         return (int64_t)ret_conv;
16239 }
16240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16241         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
16242         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
16243         return ret_conv;
16244 }
16245
16246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16247         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
16248         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16249         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
16250         return (int64_t)ret_conv;
16251 }
16252
16253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16254         LDKCVec_MessageSendEventZ _res_constr;
16255         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16256         if (_res_constr.datalen > 0)
16257                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
16258         else
16259                 _res_constr.data = NULL;
16260         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16261         for (size_t s = 0; s < _res_constr.datalen; s++) {
16262                 int64_t _res_conv_18 = _res_vals[s];
16263                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
16264                 CHECK_ACCESS(_res_conv_18_ptr);
16265                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
16266                 FREE((void*)_res_conv_18);
16267                 _res_constr.data[s] = _res_conv_18_conv;
16268         }
16269         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16270         CVec_MessageSendEventZ_free(_res_constr);
16271 }
16272
16273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16274         LDKFixedPenaltyScorer o_conv;
16275         o_conv.inner = (void*)(o & (~1));
16276         o_conv.is_owned = (o & 1) || (o == 0);
16277         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16278         o_conv = FixedPenaltyScorer_clone(&o_conv);
16279         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16280         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
16281         return (int64_t)ret_conv;
16282 }
16283
16284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16285         LDKDecodeError e_conv;
16286         e_conv.inner = (void*)(e & (~1));
16287         e_conv.is_owned = (e & 1) || (e == 0);
16288         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16289         e_conv = DecodeError_clone(&e_conv);
16290         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16291         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
16292         return (int64_t)ret_conv;
16293 }
16294
16295 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16296         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
16297         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
16298         return ret_conv;
16299 }
16300
16301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16302         if ((_res & 1) != 0) return;
16303         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16304         CHECK_ACCESS(_res_ptr);
16305         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
16306         FREE((void*)_res);
16307         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
16308 }
16309
16310 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
16311         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16312         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
16313         return (int64_t)ret_conv;
16314 }
16315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16316         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
16317         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
16318         return ret_conv;
16319 }
16320
16321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16322         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
16323         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
16324         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
16325         return (int64_t)ret_conv;
16326 }
16327
16328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16329         LDKScoringParameters o_conv;
16330         o_conv.inner = (void*)(o & (~1));
16331         o_conv.is_owned = (o & 1) || (o == 0);
16332         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16333         o_conv = ScoringParameters_clone(&o_conv);
16334         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16335         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
16336         return (int64_t)ret_conv;
16337 }
16338
16339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16340         LDKDecodeError e_conv;
16341         e_conv.inner = (void*)(e & (~1));
16342         e_conv.is_owned = (e & 1) || (e == 0);
16343         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16344         e_conv = DecodeError_clone(&e_conv);
16345         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16346         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
16347         return (int64_t)ret_conv;
16348 }
16349
16350 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16351         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
16352         jboolean ret_conv = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
16353         return ret_conv;
16354 }
16355
16356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16357         if ((_res & 1) != 0) return;
16358         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16359         CHECK_ACCESS(_res_ptr);
16360         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
16361         FREE((void*)_res);
16362         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
16363 }
16364
16365 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
16366         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16367         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
16368         return (int64_t)ret_conv;
16369 }
16370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16371         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
16372         int64_t ret_conv = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
16373         return ret_conv;
16374 }
16375
16376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16377         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
16378         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
16379         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
16380         return (int64_t)ret_conv;
16381 }
16382
16383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16384         LDKScorer o_conv;
16385         o_conv.inner = (void*)(o & (~1));
16386         o_conv.is_owned = (o & 1) || (o == 0);
16387         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16388         // WARNING: we need a move here but no clone is available for LDKScorer
16389         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
16390         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
16391         return (int64_t)ret_conv;
16392 }
16393
16394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16395         LDKDecodeError e_conv;
16396         e_conv.inner = (void*)(e & (~1));
16397         e_conv.is_owned = (e & 1) || (e == 0);
16398         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16399         e_conv = DecodeError_clone(&e_conv);
16400         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
16401         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
16402         return (int64_t)ret_conv;
16403 }
16404
16405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16406         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
16407         jboolean ret_conv = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
16408         return ret_conv;
16409 }
16410
16411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16412         if ((_res & 1) != 0) return;
16413         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16414         CHECK_ACCESS(_res_ptr);
16415         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
16416         FREE((void*)_res);
16417         CResult_ScorerDecodeErrorZ_free(_res_conv);
16418 }
16419
16420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16421         LDKProbabilisticScorer o_conv;
16422         o_conv.inner = (void*)(o & (~1));
16423         o_conv.is_owned = (o & 1) || (o == 0);
16424         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16425         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
16426         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16427         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
16428         return (int64_t)ret_conv;
16429 }
16430
16431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16432         LDKDecodeError e_conv;
16433         e_conv.inner = (void*)(e & (~1));
16434         e_conv.is_owned = (e & 1) || (e == 0);
16435         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16436         e_conv = DecodeError_clone(&e_conv);
16437         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
16438         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
16439         return (int64_t)ret_conv;
16440 }
16441
16442 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16443         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
16444         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
16445         return ret_conv;
16446 }
16447
16448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16449         if ((_res & 1) != 0) return;
16450         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16451         CHECK_ACCESS(_res_ptr);
16452         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
16453         FREE((void*)_res);
16454         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
16455 }
16456
16457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16458         LDKInitFeatures o_conv;
16459         o_conv.inner = (void*)(o & (~1));
16460         o_conv.is_owned = (o & 1) || (o == 0);
16461         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16462         o_conv = InitFeatures_clone(&o_conv);
16463         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16464         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
16465         return (int64_t)ret_conv;
16466 }
16467
16468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16469         LDKDecodeError e_conv;
16470         e_conv.inner = (void*)(e & (~1));
16471         e_conv.is_owned = (e & 1) || (e == 0);
16472         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16473         e_conv = DecodeError_clone(&e_conv);
16474         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
16475         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
16476         return (int64_t)ret_conv;
16477 }
16478
16479 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16480         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
16481         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
16482         return ret_conv;
16483 }
16484
16485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16486         if ((_res & 1) != 0) return;
16487         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16488         CHECK_ACCESS(_res_ptr);
16489         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
16490         FREE((void*)_res);
16491         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
16492 }
16493
16494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16495         LDKChannelFeatures o_conv;
16496         o_conv.inner = (void*)(o & (~1));
16497         o_conv.is_owned = (o & 1) || (o == 0);
16498         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16499         o_conv = ChannelFeatures_clone(&o_conv);
16500         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16501         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
16502         return (int64_t)ret_conv;
16503 }
16504
16505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16506         LDKDecodeError e_conv;
16507         e_conv.inner = (void*)(e & (~1));
16508         e_conv.is_owned = (e & 1) || (e == 0);
16509         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16510         e_conv = DecodeError_clone(&e_conv);
16511         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
16512         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
16513         return (int64_t)ret_conv;
16514 }
16515
16516 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16517         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
16518         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
16519         return ret_conv;
16520 }
16521
16522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16523         if ((_res & 1) != 0) return;
16524         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16525         CHECK_ACCESS(_res_ptr);
16526         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
16527         FREE((void*)_res);
16528         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
16529 }
16530
16531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16532         LDKNodeFeatures o_conv;
16533         o_conv.inner = (void*)(o & (~1));
16534         o_conv.is_owned = (o & 1) || (o == 0);
16535         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16536         o_conv = NodeFeatures_clone(&o_conv);
16537         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16538         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
16539         return (int64_t)ret_conv;
16540 }
16541
16542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16543         LDKDecodeError e_conv;
16544         e_conv.inner = (void*)(e & (~1));
16545         e_conv.is_owned = (e & 1) || (e == 0);
16546         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16547         e_conv = DecodeError_clone(&e_conv);
16548         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
16549         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
16550         return (int64_t)ret_conv;
16551 }
16552
16553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16554         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
16555         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
16556         return ret_conv;
16557 }
16558
16559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16560         if ((_res & 1) != 0) return;
16561         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16562         CHECK_ACCESS(_res_ptr);
16563         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
16564         FREE((void*)_res);
16565         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
16566 }
16567
16568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16569         LDKInvoiceFeatures o_conv;
16570         o_conv.inner = (void*)(o & (~1));
16571         o_conv.is_owned = (o & 1) || (o == 0);
16572         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16573         o_conv = InvoiceFeatures_clone(&o_conv);
16574         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16575         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
16576         return (int64_t)ret_conv;
16577 }
16578
16579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16580         LDKDecodeError e_conv;
16581         e_conv.inner = (void*)(e & (~1));
16582         e_conv.is_owned = (e & 1) || (e == 0);
16583         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16584         e_conv = DecodeError_clone(&e_conv);
16585         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
16586         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
16587         return (int64_t)ret_conv;
16588 }
16589
16590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16591         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
16592         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
16593         return ret_conv;
16594 }
16595
16596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16597         if ((_res & 1) != 0) return;
16598         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16599         CHECK_ACCESS(_res_ptr);
16600         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
16601         FREE((void*)_res);
16602         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
16603 }
16604
16605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16606         LDKChannelTypeFeatures o_conv;
16607         o_conv.inner = (void*)(o & (~1));
16608         o_conv.is_owned = (o & 1) || (o == 0);
16609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16610         o_conv = ChannelTypeFeatures_clone(&o_conv);
16611         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16612         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
16613         return (int64_t)ret_conv;
16614 }
16615
16616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16617         LDKDecodeError e_conv;
16618         e_conv.inner = (void*)(e & (~1));
16619         e_conv.is_owned = (e & 1) || (e == 0);
16620         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16621         e_conv = DecodeError_clone(&e_conv);
16622         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
16623         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
16624         return (int64_t)ret_conv;
16625 }
16626
16627 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16628         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
16629         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
16630         return ret_conv;
16631 }
16632
16633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16634         if ((_res & 1) != 0) return;
16635         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16636         CHECK_ACCESS(_res_ptr);
16637         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
16638         FREE((void*)_res);
16639         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
16640 }
16641
16642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16643         LDKDelayedPaymentOutputDescriptor o_conv;
16644         o_conv.inner = (void*)(o & (~1));
16645         o_conv.is_owned = (o & 1) || (o == 0);
16646         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16647         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
16648         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16649         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16650         return (int64_t)ret_conv;
16651 }
16652
16653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16654         LDKDecodeError e_conv;
16655         e_conv.inner = (void*)(e & (~1));
16656         e_conv.is_owned = (e & 1) || (e == 0);
16657         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16658         e_conv = DecodeError_clone(&e_conv);
16659         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16660         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16661         return (int64_t)ret_conv;
16662 }
16663
16664 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16665         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
16666         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16667         return ret_conv;
16668 }
16669
16670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16671         if ((_res & 1) != 0) return;
16672         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16673         CHECK_ACCESS(_res_ptr);
16674         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16675         FREE((void*)_res);
16676         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16677 }
16678
16679 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16680         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16681         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16682         return (int64_t)ret_conv;
16683 }
16684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16685         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
16686         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16687         return ret_conv;
16688 }
16689
16690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16691         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
16692         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16693         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16694         return (int64_t)ret_conv;
16695 }
16696
16697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16698         LDKStaticPaymentOutputDescriptor o_conv;
16699         o_conv.inner = (void*)(o & (~1));
16700         o_conv.is_owned = (o & 1) || (o == 0);
16701         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16702         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
16703         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16704         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16705         return (int64_t)ret_conv;
16706 }
16707
16708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16709         LDKDecodeError e_conv;
16710         e_conv.inner = (void*)(e & (~1));
16711         e_conv.is_owned = (e & 1) || (e == 0);
16712         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16713         e_conv = DecodeError_clone(&e_conv);
16714         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16715         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16716         return (int64_t)ret_conv;
16717 }
16718
16719 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16720         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
16721         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16722         return ret_conv;
16723 }
16724
16725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16726         if ((_res & 1) != 0) return;
16727         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16728         CHECK_ACCESS(_res_ptr);
16729         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16730         FREE((void*)_res);
16731         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16732 }
16733
16734 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16735         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16736         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16737         return (int64_t)ret_conv;
16738 }
16739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16740         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
16741         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16742         return ret_conv;
16743 }
16744
16745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16746         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
16747         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16748         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16749         return (int64_t)ret_conv;
16750 }
16751
16752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16753         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16754         CHECK_ACCESS(o_ptr);
16755         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
16756         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
16757         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16758         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
16759         return (int64_t)ret_conv;
16760 }
16761
16762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16763         LDKDecodeError e_conv;
16764         e_conv.inner = (void*)(e & (~1));
16765         e_conv.is_owned = (e & 1) || (e == 0);
16766         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16767         e_conv = DecodeError_clone(&e_conv);
16768         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16769         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
16770         return (int64_t)ret_conv;
16771 }
16772
16773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16774         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
16775         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16776         return ret_conv;
16777 }
16778
16779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16780         if ((_res & 1) != 0) return;
16781         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16782         CHECK_ACCESS(_res_ptr);
16783         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
16784         FREE((void*)_res);
16785         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
16786 }
16787
16788 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16789         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16790         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
16791         return (int64_t)ret_conv;
16792 }
16793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16794         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
16795         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16796         return ret_conv;
16797 }
16798
16799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16800         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
16801         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16802         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
16803         return (int64_t)ret_conv;
16804 }
16805
16806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16807         LDKCVec_PaymentPreimageZ _res_constr;
16808         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16809         if (_res_constr.datalen > 0)
16810                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
16811         else
16812                 _res_constr.data = NULL;
16813         for (size_t i = 0; i < _res_constr.datalen; i++) {
16814                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16815                 LDKThirtyTwoBytes _res_conv_8_ref;
16816                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
16817                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
16818                 _res_constr.data[i] = _res_conv_8_ref;
16819         }
16820         CVec_PaymentPreimageZ_free(_res_constr);
16821 }
16822
16823 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
16824         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16825         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
16826         return ((int64_t)ret_conv);
16827 }
16828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16829         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
16830         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
16831         return ret_conv;
16832 }
16833
16834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16835         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
16836         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16837         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
16838         return ((int64_t)ret_conv);
16839 }
16840
16841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
16842         LDKSignature a_ref;
16843         CHECK((*env)->GetArrayLength(env, a) == 64);
16844         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
16845         LDKCVec_SignatureZ b_constr;
16846         b_constr.datalen = (*env)->GetArrayLength(env, b);
16847         if (b_constr.datalen > 0)
16848                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16849         else
16850                 b_constr.data = NULL;
16851         for (size_t i = 0; i < b_constr.datalen; i++) {
16852                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
16853                 LDKSignature b_conv_8_ref;
16854                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
16855                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
16856                 b_constr.data[i] = b_conv_8_ref;
16857         }
16858         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
16859         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
16860         return ((int64_t)ret_conv);
16861 }
16862
16863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16864         if ((_res & 1) != 0) return;
16865         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16866         CHECK_ACCESS(_res_ptr);
16867         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
16868         FREE((void*)_res);
16869         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
16870 }
16871
16872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16873         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16874         CHECK_ACCESS(o_ptr);
16875         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
16876         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
16877         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16878         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
16879         return (int64_t)ret_conv;
16880 }
16881
16882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
16883         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16884         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
16885         return (int64_t)ret_conv;
16886 }
16887
16888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16889         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
16890         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
16891         return ret_conv;
16892 }
16893
16894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16895         if ((_res & 1) != 0) return;
16896         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16897         CHECK_ACCESS(_res_ptr);
16898         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
16899         FREE((void*)_res);
16900         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
16901 }
16902
16903 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
16904         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16905         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
16906         return (int64_t)ret_conv;
16907 }
16908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16909         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
16910         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
16911         return ret_conv;
16912 }
16913
16914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16915         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
16916         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
16917         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
16918         return (int64_t)ret_conv;
16919 }
16920
16921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16922         LDKSignature o_ref;
16923         CHECK((*env)->GetArrayLength(env, o) == 64);
16924         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
16925         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16926         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
16927         return (int64_t)ret_conv;
16928 }
16929
16930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
16931         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16932         *ret_conv = CResult_SignatureNoneZ_err();
16933         return (int64_t)ret_conv;
16934 }
16935
16936 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16937         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
16938         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
16939         return ret_conv;
16940 }
16941
16942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16943         if ((_res & 1) != 0) return;
16944         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16945         CHECK_ACCESS(_res_ptr);
16946         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
16947         FREE((void*)_res);
16948         CResult_SignatureNoneZ_free(_res_conv);
16949 }
16950
16951 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
16952         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16953         *ret_conv = CResult_SignatureNoneZ_clone(arg);
16954         return (int64_t)ret_conv;
16955 }
16956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16957         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
16958         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
16959         return ret_conv;
16960 }
16961
16962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16963         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
16964         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
16965         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
16966         return (int64_t)ret_conv;
16967 }
16968
16969 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
16970         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16971         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
16972         return ((int64_t)ret_conv);
16973 }
16974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16975         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
16976         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
16977         return ret_conv;
16978 }
16979
16980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16981         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
16982         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16983         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
16984         return ((int64_t)ret_conv);
16985 }
16986
16987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
16988         LDKSignature a_ref;
16989         CHECK((*env)->GetArrayLength(env, a) == 64);
16990         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
16991         LDKSignature b_ref;
16992         CHECK((*env)->GetArrayLength(env, b) == 64);
16993         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
16994         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
16995         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
16996         return ((int64_t)ret_conv);
16997 }
16998
16999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17000         if ((_res & 1) != 0) return;
17001         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17002         CHECK_ACCESS(_res_ptr);
17003         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
17004         FREE((void*)_res);
17005         C2Tuple_SignatureSignatureZ_free(_res_conv);
17006 }
17007
17008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17009         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17010         CHECK_ACCESS(o_ptr);
17011         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
17012         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
17013         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17014         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
17015         return (int64_t)ret_conv;
17016 }
17017
17018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
17019         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17020         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
17021         return (int64_t)ret_conv;
17022 }
17023
17024 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17025         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
17026         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
17027         return ret_conv;
17028 }
17029
17030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17031         if ((_res & 1) != 0) return;
17032         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17033         CHECK_ACCESS(_res_ptr);
17034         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
17035         FREE((void*)_res);
17036         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
17037 }
17038
17039 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
17040         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17041         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
17042         return (int64_t)ret_conv;
17043 }
17044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17045         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
17046         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
17047         return ret_conv;
17048 }
17049
17050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17051         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
17052         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
17053         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
17054         return (int64_t)ret_conv;
17055 }
17056
17057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17058         LDKSecretKey o_ref;
17059         CHECK((*env)->GetArrayLength(env, o) == 32);
17060         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
17061         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17062         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
17063         return (int64_t)ret_conv;
17064 }
17065
17066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
17067         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17068         *ret_conv = CResult_SecretKeyNoneZ_err();
17069         return (int64_t)ret_conv;
17070 }
17071
17072 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17073         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
17074         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
17075         return ret_conv;
17076 }
17077
17078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17079         if ((_res & 1) != 0) return;
17080         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17081         CHECK_ACCESS(_res_ptr);
17082         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
17083         FREE((void*)_res);
17084         CResult_SecretKeyNoneZ_free(_res_conv);
17085 }
17086
17087 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
17088         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17089         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
17090         return (int64_t)ret_conv;
17091 }
17092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17093         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
17094         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
17095         return ret_conv;
17096 }
17097
17098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17099         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
17100         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
17101         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
17102         return (int64_t)ret_conv;
17103 }
17104
17105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17106         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17107         CHECK_ACCESS(o_ptr);
17108         LDKSign o_conv = *(LDKSign*)(o_ptr);
17109         if (o_conv.free == LDKSign_JCalls_free) {
17110                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17111                 LDKSign_JCalls_cloned(&o_conv);
17112         }
17113         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17114         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
17115         return (int64_t)ret_conv;
17116 }
17117
17118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17119         LDKDecodeError e_conv;
17120         e_conv.inner = (void*)(e & (~1));
17121         e_conv.is_owned = (e & 1) || (e == 0);
17122         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17123         e_conv = DecodeError_clone(&e_conv);
17124         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17125         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
17126         return (int64_t)ret_conv;
17127 }
17128
17129 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17130         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
17131         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
17132         return ret_conv;
17133 }
17134
17135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17136         if ((_res & 1) != 0) return;
17137         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17138         CHECK_ACCESS(_res_ptr);
17139         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
17140         FREE((void*)_res);
17141         CResult_SignDecodeErrorZ_free(_res_conv);
17142 }
17143
17144 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
17145         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17146         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
17147         return (int64_t)ret_conv;
17148 }
17149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17150         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
17151         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
17152         return ret_conv;
17153 }
17154
17155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17156         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
17157         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
17158         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
17159         return (int64_t)ret_conv;
17160 }
17161
17162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17163         LDKCVec_u5Z _res_constr;
17164         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17165         if (_res_constr.datalen > 0)
17166                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
17167         else
17168                 _res_constr.data = NULL;
17169         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
17170         for (size_t h = 0; h < _res_constr.datalen; h++) {
17171                 int8_t _res_conv_7 = _res_vals[h];
17172                 
17173                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
17174         }
17175         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
17176         CVec_u5Z_free(_res_constr);
17177 }
17178
17179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17180         LDKRecoverableSignature o_ref;
17181         CHECK((*env)->GetArrayLength(env, o) == 68);
17182         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
17183         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17184         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
17185         return (int64_t)ret_conv;
17186 }
17187
17188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
17189         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17190         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
17191         return (int64_t)ret_conv;
17192 }
17193
17194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17195         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
17196         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
17197         return ret_conv;
17198 }
17199
17200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17201         if ((_res & 1) != 0) return;
17202         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17203         CHECK_ACCESS(_res_ptr);
17204         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
17205         FREE((void*)_res);
17206         CResult_RecoverableSignatureNoneZ_free(_res_conv);
17207 }
17208
17209 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
17210         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17211         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
17212         return (int64_t)ret_conv;
17213 }
17214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17215         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
17216         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
17217         return ret_conv;
17218 }
17219
17220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17221         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
17222         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17223         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
17224         return (int64_t)ret_conv;
17225 }
17226
17227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
17228         LDKCVec_u8Z _res_ref;
17229         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
17230         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
17231         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
17232         CVec_u8Z_free(_res_ref);
17233 }
17234
17235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17236         LDKCVec_CVec_u8ZZ _res_constr;
17237         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17238         if (_res_constr.datalen > 0)
17239                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17240         else
17241                 _res_constr.data = NULL;
17242         for (size_t i = 0; i < _res_constr.datalen; i++) {
17243                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17244                 LDKCVec_u8Z _res_conv_8_ref;
17245                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
17246                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17247                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
17248                 _res_constr.data[i] = _res_conv_8_ref;
17249         }
17250         CVec_CVec_u8ZZ_free(_res_constr);
17251 }
17252
17253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
17254         LDKCVec_CVec_u8ZZ o_constr;
17255         o_constr.datalen = (*env)->GetArrayLength(env, o);
17256         if (o_constr.datalen > 0)
17257                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17258         else
17259                 o_constr.data = NULL;
17260         for (size_t i = 0; i < o_constr.datalen; i++) {
17261                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
17262                 LDKCVec_u8Z o_conv_8_ref;
17263                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
17264                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17265                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
17266                 o_constr.data[i] = o_conv_8_ref;
17267         }
17268         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17269         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
17270         return (int64_t)ret_conv;
17271 }
17272
17273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
17274         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17275         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
17276         return (int64_t)ret_conv;
17277 }
17278
17279 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17280         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
17281         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
17282         return ret_conv;
17283 }
17284
17285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17286         if ((_res & 1) != 0) return;
17287         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17288         CHECK_ACCESS(_res_ptr);
17289         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
17290         FREE((void*)_res);
17291         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
17292 }
17293
17294 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
17295         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17296         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
17297         return (int64_t)ret_conv;
17298 }
17299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17300         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
17301         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
17302         return ret_conv;
17303 }
17304
17305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17306         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
17307         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17308         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
17309         return (int64_t)ret_conv;
17310 }
17311
17312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17313         LDKInMemorySigner o_conv;
17314         o_conv.inner = (void*)(o & (~1));
17315         o_conv.is_owned = (o & 1) || (o == 0);
17316         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17317         o_conv = InMemorySigner_clone(&o_conv);
17318         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17319         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
17320         return (int64_t)ret_conv;
17321 }
17322
17323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17324         LDKDecodeError e_conv;
17325         e_conv.inner = (void*)(e & (~1));
17326         e_conv.is_owned = (e & 1) || (e == 0);
17327         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17328         e_conv = DecodeError_clone(&e_conv);
17329         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17330         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
17331         return (int64_t)ret_conv;
17332 }
17333
17334 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17335         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
17336         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
17337         return ret_conv;
17338 }
17339
17340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17341         if ((_res & 1) != 0) return;
17342         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17343         CHECK_ACCESS(_res_ptr);
17344         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
17345         FREE((void*)_res);
17346         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
17347 }
17348
17349 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
17350         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17351         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
17352         return (int64_t)ret_conv;
17353 }
17354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17355         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
17356         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
17357         return ret_conv;
17358 }
17359
17360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17361         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
17362         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17363         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
17364         return (int64_t)ret_conv;
17365 }
17366
17367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17368         LDKCVec_TxOutZ _res_constr;
17369         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17370         if (_res_constr.datalen > 0)
17371                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
17372         else
17373                 _res_constr.data = NULL;
17374         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17375         for (size_t h = 0; h < _res_constr.datalen; h++) {
17376                 int64_t _res_conv_7 = _res_vals[h];
17377                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
17378                 CHECK_ACCESS(_res_conv_7_ptr);
17379                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
17380                 FREE((void*)_res_conv_7);
17381                 _res_constr.data[h] = _res_conv_7_conv;
17382         }
17383         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17384         CVec_TxOutZ_free(_res_constr);
17385 }
17386
17387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17388         LDKTransaction o_ref;
17389         o_ref.datalen = (*env)->GetArrayLength(env, o);
17390         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
17391         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
17392         o_ref.data_is_owned = true;
17393         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17394         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
17395         return (int64_t)ret_conv;
17396 }
17397
17398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
17399         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17400         *ret_conv = CResult_TransactionNoneZ_err();
17401         return (int64_t)ret_conv;
17402 }
17403
17404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17405         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
17406         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
17407         return ret_conv;
17408 }
17409
17410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17411         if ((_res & 1) != 0) return;
17412         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17413         CHECK_ACCESS(_res_ptr);
17414         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
17415         FREE((void*)_res);
17416         CResult_TransactionNoneZ_free(_res_conv);
17417 }
17418
17419 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
17420         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17421         *ret_conv = CResult_TransactionNoneZ_clone(arg);
17422         return (int64_t)ret_conv;
17423 }
17424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17425         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
17426         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
17427         return ret_conv;
17428 }
17429
17430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17431         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
17432         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17433         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
17434         return (int64_t)ret_conv;
17435 }
17436
17437 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
17438         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17439         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
17440         return ((int64_t)ret_conv);
17441 }
17442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17443         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
17444         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
17445         return ret_conv;
17446 }
17447
17448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17449         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
17450         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17451         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
17452         return ((int64_t)ret_conv);
17453 }
17454
17455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
17456         LDKThirtyTwoBytes a_ref;
17457         CHECK((*env)->GetArrayLength(env, a) == 32);
17458         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17459         LDKChannelMonitor b_conv;
17460         b_conv.inner = (void*)(b & (~1));
17461         b_conv.is_owned = (b & 1) || (b == 0);
17462         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17463         b_conv = ChannelMonitor_clone(&b_conv);
17464         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17465         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
17466         return ((int64_t)ret_conv);
17467 }
17468
17469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17470         if ((_res & 1) != 0) return;
17471         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17472         CHECK_ACCESS(_res_ptr);
17473         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
17474         FREE((void*)_res);
17475         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
17476 }
17477
17478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17479         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
17480         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17481         if (_res_constr.datalen > 0)
17482                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
17483         else
17484                 _res_constr.data = NULL;
17485         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17486         for (size_t j = 0; j < _res_constr.datalen; j++) {
17487                 int64_t _res_conv_35 = _res_vals[j];
17488                 void* _res_conv_35_ptr = (void*)(((uintptr_t)_res_conv_35) & ~1);
17489                 CHECK_ACCESS(_res_conv_35_ptr);
17490                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
17491                 FREE((void*)_res_conv_35);
17492                 _res_constr.data[j] = _res_conv_35_conv;
17493         }
17494         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17495         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
17496 }
17497
17498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
17499         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
17500         o_constr.datalen = (*env)->GetArrayLength(env, o);
17501         if (o_constr.datalen > 0)
17502                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
17503         else
17504                 o_constr.data = NULL;
17505         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
17506         for (size_t j = 0; j < o_constr.datalen; j++) {
17507                 int64_t o_conv_35 = o_vals[j];
17508                 void* o_conv_35_ptr = (void*)(((uintptr_t)o_conv_35) & ~1);
17509                 CHECK_ACCESS(o_conv_35_ptr);
17510                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
17511                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o_conv_35) & ~1));
17512                 o_constr.data[j] = o_conv_35_conv;
17513         }
17514         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
17515         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17516         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
17517         return (int64_t)ret_conv;
17518 }
17519
17520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17521         LDKIOError e_conv = LDKIOError_from_java(env, e);
17522         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17523         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
17524         return (int64_t)ret_conv;
17525 }
17526
17527 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17528         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
17529         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
17530         return ret_conv;
17531 }
17532
17533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17534         if ((_res & 1) != 0) return;
17535         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17536         CHECK_ACCESS(_res_ptr);
17537         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
17538         FREE((void*)_res);
17539         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
17540 }
17541
17542 static inline uintptr_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
17543         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17544         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
17545         return (int64_t)ret_conv;
17546 }
17547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17548         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
17549         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
17550         return ret_conv;
17551 }
17552
17553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17554         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
17555         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
17556         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
17557         return (int64_t)ret_conv;
17558 }
17559
17560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
17561         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17562         *ret_copy = COption_u16Z_some(o);
17563         int64_t ret_ref = (uintptr_t)ret_copy;
17564         return ret_ref;
17565 }
17566
17567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
17568         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17569         *ret_copy = COption_u16Z_none();
17570         int64_t ret_ref = (uintptr_t)ret_copy;
17571         return ret_ref;
17572 }
17573
17574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17575         if ((_res & 1) != 0) return;
17576         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17577         CHECK_ACCESS(_res_ptr);
17578         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
17579         FREE((void*)_res);
17580         COption_u16Z_free(_res_conv);
17581 }
17582
17583 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
17584         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17585         *ret_copy = COption_u16Z_clone(arg);
17586 int64_t ret_ref = (uintptr_t)ret_copy;
17587         return ret_ref;
17588 }
17589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17590         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
17591         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
17592         return ret_conv;
17593 }
17594
17595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17596         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
17597         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17598         *ret_copy = COption_u16Z_clone(orig_conv);
17599         int64_t ret_ref = (uintptr_t)ret_copy;
17600         return ret_ref;
17601 }
17602
17603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
17604         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17605         *ret_conv = CResult_NoneAPIErrorZ_ok();
17606         return (int64_t)ret_conv;
17607 }
17608
17609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17610         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17611         CHECK_ACCESS(e_ptr);
17612         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17613         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17614         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17615         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
17616         return (int64_t)ret_conv;
17617 }
17618
17619 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17620         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
17621         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
17622         return ret_conv;
17623 }
17624
17625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17626         if ((_res & 1) != 0) return;
17627         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17628         CHECK_ACCESS(_res_ptr);
17629         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
17630         FREE((void*)_res);
17631         CResult_NoneAPIErrorZ_free(_res_conv);
17632 }
17633
17634 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
17635         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17636         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
17637         return (int64_t)ret_conv;
17638 }
17639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17640         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
17641         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
17642         return ret_conv;
17643 }
17644
17645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17646         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
17647         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
17648         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
17649         return (int64_t)ret_conv;
17650 }
17651
17652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17653         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
17654         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17655         if (_res_constr.datalen > 0)
17656                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
17657         else
17658                 _res_constr.data = NULL;
17659         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17660         for (size_t w = 0; w < _res_constr.datalen; w++) {
17661                 int64_t _res_conv_22 = _res_vals[w];
17662                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
17663                 CHECK_ACCESS(_res_conv_22_ptr);
17664                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
17665                 FREE((void*)_res_conv_22);
17666                 _res_constr.data[w] = _res_conv_22_conv;
17667         }
17668         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17669         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
17670 }
17671
17672 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17673         LDKCVec_APIErrorZ _res_constr;
17674         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17675         if (_res_constr.datalen > 0)
17676                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
17677         else
17678                 _res_constr.data = NULL;
17679         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17680         for (size_t k = 0; k < _res_constr.datalen; k++) {
17681                 int64_t _res_conv_10 = _res_vals[k];
17682                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
17683                 CHECK_ACCESS(_res_conv_10_ptr);
17684                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
17685                 FREE((void*)_res_conv_10);
17686                 _res_constr.data[k] = _res_conv_10_conv;
17687         }
17688         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17689         CVec_APIErrorZ_free(_res_constr);
17690 }
17691
17692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17693         LDKThirtyTwoBytes o_ref;
17694         CHECK((*env)->GetArrayLength(env, o) == 32);
17695         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17696         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17697         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
17698         return (int64_t)ret_conv;
17699 }
17700
17701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17702         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17703         CHECK_ACCESS(e_ptr);
17704         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
17705         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
17706         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17707         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
17708         return (int64_t)ret_conv;
17709 }
17710
17711 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17712         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
17713         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
17714         return ret_conv;
17715 }
17716
17717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17718         if ((_res & 1) != 0) return;
17719         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17720         CHECK_ACCESS(_res_ptr);
17721         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
17722         FREE((void*)_res);
17723         CResult__u832APIErrorZ_free(_res_conv);
17724 }
17725
17726 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
17727         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17728         *ret_conv = CResult__u832APIErrorZ_clone(arg);
17729         return (int64_t)ret_conv;
17730 }
17731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17732         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
17733         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
17734         return ret_conv;
17735 }
17736
17737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17738         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
17739         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
17740         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
17741         return (int64_t)ret_conv;
17742 }
17743
17744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
17745         LDKThirtyTwoBytes o_ref;
17746         CHECK((*env)->GetArrayLength(env, o) == 32);
17747         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
17748         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17749         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
17750         return (int64_t)ret_conv;
17751 }
17752
17753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17754         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17755         CHECK_ACCESS(e_ptr);
17756         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17757         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17758         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17759         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
17760         return (int64_t)ret_conv;
17761 }
17762
17763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17764         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
17765         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
17766         return ret_conv;
17767 }
17768
17769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17770         if ((_res & 1) != 0) return;
17771         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17772         CHECK_ACCESS(_res_ptr);
17773         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
17774         FREE((void*)_res);
17775         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
17776 }
17777
17778 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
17779         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17780         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
17781         return (int64_t)ret_conv;
17782 }
17783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17784         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
17785         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
17786         return ret_conv;
17787 }
17788
17789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17790         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
17791         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
17792         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
17793         return (int64_t)ret_conv;
17794 }
17795
17796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
17797         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17798         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
17799         return (int64_t)ret_conv;
17800 }
17801
17802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17803         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17804         CHECK_ACCESS(e_ptr);
17805         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17806         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17807         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17808         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
17809         return (int64_t)ret_conv;
17810 }
17811
17812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17813         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
17814         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
17815         return ret_conv;
17816 }
17817
17818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17819         if ((_res & 1) != 0) return;
17820         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17821         CHECK_ACCESS(_res_ptr);
17822         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
17823         FREE((void*)_res);
17824         CResult_NonePaymentSendFailureZ_free(_res_conv);
17825 }
17826
17827 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
17828         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17829         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
17830         return (int64_t)ret_conv;
17831 }
17832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17833         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
17834         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
17835         return ret_conv;
17836 }
17837
17838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17839         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
17840         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
17841         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
17842         return (int64_t)ret_conv;
17843 }
17844
17845 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
17846         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17847         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
17848         return ((int64_t)ret_conv);
17849 }
17850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17851         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
17852         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
17853         return ret_conv;
17854 }
17855
17856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17857         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
17858         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17859         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
17860         return ((int64_t)ret_conv);
17861 }
17862
17863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
17864         LDKThirtyTwoBytes a_ref;
17865         CHECK((*env)->GetArrayLength(env, a) == 32);
17866         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17867         LDKThirtyTwoBytes b_ref;
17868         CHECK((*env)->GetArrayLength(env, b) == 32);
17869         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
17870         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
17871         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
17872         return ((int64_t)ret_conv);
17873 }
17874
17875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17876         if ((_res & 1) != 0) return;
17877         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17878         CHECK_ACCESS(_res_ptr);
17879         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
17880         FREE((void*)_res);
17881         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
17882 }
17883
17884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17885         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17886         CHECK_ACCESS(o_ptr);
17887         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
17888         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
17889         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17890         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
17891         return (int64_t)ret_conv;
17892 }
17893
17894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17895         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
17896         CHECK_ACCESS(e_ptr);
17897         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
17898         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
17899         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17900         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
17901         return (int64_t)ret_conv;
17902 }
17903
17904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17905         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
17906         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
17907         return ret_conv;
17908 }
17909
17910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17911         if ((_res & 1) != 0) return;
17912         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17913         CHECK_ACCESS(_res_ptr);
17914         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
17915         FREE((void*)_res);
17916         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
17917 }
17918
17919 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
17920         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17921         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
17922         return (int64_t)ret_conv;
17923 }
17924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17925         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
17926         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
17927         return ret_conv;
17928 }
17929
17930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17931         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
17932         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
17933         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
17934         return (int64_t)ret_conv;
17935 }
17936
17937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17938         LDKCVec_NetAddressZ _res_constr;
17939         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17940         if (_res_constr.datalen > 0)
17941                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17942         else
17943                 _res_constr.data = NULL;
17944         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17945         for (size_t m = 0; m < _res_constr.datalen; m++) {
17946                 int64_t _res_conv_12 = _res_vals[m];
17947                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
17948                 CHECK_ACCESS(_res_conv_12_ptr);
17949                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
17950                 FREE((void*)_res_conv_12);
17951                 _res_constr.data[m] = _res_conv_12_conv;
17952         }
17953         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17954         CVec_NetAddressZ_free(_res_constr);
17955 }
17956
17957 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
17958         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17959         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
17960         return ((int64_t)ret_conv);
17961 }
17962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17963         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
17964         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
17965         return ret_conv;
17966 }
17967
17968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17969         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
17970         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17971         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
17972         return ((int64_t)ret_conv);
17973 }
17974
17975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
17976         LDKThirtyTwoBytes a_ref;
17977         CHECK((*env)->GetArrayLength(env, a) == 32);
17978         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
17979         LDKThirtyTwoBytes b_ref;
17980         CHECK((*env)->GetArrayLength(env, b) == 32);
17981         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
17982         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
17983         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
17984         return ((int64_t)ret_conv);
17985 }
17986
17987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17988         if ((_res & 1) != 0) return;
17989         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17990         CHECK_ACCESS(_res_ptr);
17991         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
17992         FREE((void*)_res);
17993         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
17994 }
17995
17996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17997         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17998         CHECK_ACCESS(o_ptr);
17999         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
18000         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
18001         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18002         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
18003         return (int64_t)ret_conv;
18004 }
18005
18006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
18007         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18008         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
18009         return (int64_t)ret_conv;
18010 }
18011
18012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18013         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
18014         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
18015         return ret_conv;
18016 }
18017
18018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18019         if ((_res & 1) != 0) return;
18020         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18021         CHECK_ACCESS(_res_ptr);
18022         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
18023         FREE((void*)_res);
18024         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
18025 }
18026
18027 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
18028         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18029         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
18030         return (int64_t)ret_conv;
18031 }
18032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18033         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
18034         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
18035         return ret_conv;
18036 }
18037
18038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18039         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
18040         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
18041         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
18042         return (int64_t)ret_conv;
18043 }
18044
18045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18046         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18047         CHECK_ACCESS(o_ptr);
18048         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
18049         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
18050         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18051         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
18052         return (int64_t)ret_conv;
18053 }
18054
18055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18056         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18057         CHECK_ACCESS(e_ptr);
18058         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18059         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
18060         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18061         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
18062         return (int64_t)ret_conv;
18063 }
18064
18065 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18066         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
18067         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
18068         return ret_conv;
18069 }
18070
18071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18072         if ((_res & 1) != 0) return;
18073         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18074         CHECK_ACCESS(_res_ptr);
18075         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
18076         FREE((void*)_res);
18077         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
18078 }
18079
18080 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
18081         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18082         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
18083         return (int64_t)ret_conv;
18084 }
18085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18086         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
18087         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
18088         return ret_conv;
18089 }
18090
18091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18092         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
18093         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
18094         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
18095         return (int64_t)ret_conv;
18096 }
18097
18098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18099         LDKThirtyTwoBytes o_ref;
18100         CHECK((*env)->GetArrayLength(env, o) == 32);
18101         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18102         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18103         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
18104         return (int64_t)ret_conv;
18105 }
18106
18107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
18108         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18109         *ret_conv = CResult_PaymentSecretNoneZ_err();
18110         return (int64_t)ret_conv;
18111 }
18112
18113 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18114         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
18115         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
18116         return ret_conv;
18117 }
18118
18119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18120         if ((_res & 1) != 0) return;
18121         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18122         CHECK_ACCESS(_res_ptr);
18123         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
18124         FREE((void*)_res);
18125         CResult_PaymentSecretNoneZ_free(_res_conv);
18126 }
18127
18128 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
18129         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18130         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
18131         return (int64_t)ret_conv;
18132 }
18133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18134         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
18135         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
18136         return ret_conv;
18137 }
18138
18139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18140         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
18141         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
18142         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
18143         return (int64_t)ret_conv;
18144 }
18145
18146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18147         LDKThirtyTwoBytes o_ref;
18148         CHECK((*env)->GetArrayLength(env, o) == 32);
18149         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18150         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18151         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
18152         return (int64_t)ret_conv;
18153 }
18154
18155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18156         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18157         CHECK_ACCESS(e_ptr);
18158         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18159         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
18160         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18161         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
18162         return (int64_t)ret_conv;
18163 }
18164
18165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18166         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
18167         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
18168         return ret_conv;
18169 }
18170
18171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18172         if ((_res & 1) != 0) return;
18173         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18174         CHECK_ACCESS(_res_ptr);
18175         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
18176         FREE((void*)_res);
18177         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
18178 }
18179
18180 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
18181         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18182         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
18183         return (int64_t)ret_conv;
18184 }
18185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18186         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
18187         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
18188         return ret_conv;
18189 }
18190
18191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18192         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
18193         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
18194         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
18195         return (int64_t)ret_conv;
18196 }
18197
18198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18199         LDKThirtyTwoBytes o_ref;
18200         CHECK((*env)->GetArrayLength(env, o) == 32);
18201         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18202         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18203         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
18204         return (int64_t)ret_conv;
18205 }
18206
18207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18208         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18209         CHECK_ACCESS(e_ptr);
18210         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
18211         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
18212         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18213         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
18214         return (int64_t)ret_conv;
18215 }
18216
18217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18218         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
18219         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
18220         return ret_conv;
18221 }
18222
18223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18224         if ((_res & 1) != 0) return;
18225         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18226         CHECK_ACCESS(_res_ptr);
18227         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
18228         FREE((void*)_res);
18229         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
18230 }
18231
18232 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
18233         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18234         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
18235         return (int64_t)ret_conv;
18236 }
18237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18238         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
18239         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
18240         return ret_conv;
18241 }
18242
18243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18244         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
18245         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
18246         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
18247         return (int64_t)ret_conv;
18248 }
18249
18250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18251         LDKCounterpartyForwardingInfo o_conv;
18252         o_conv.inner = (void*)(o & (~1));
18253         o_conv.is_owned = (o & 1) || (o == 0);
18254         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18255         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
18256         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18257         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
18258         return (int64_t)ret_conv;
18259 }
18260
18261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18262         LDKDecodeError e_conv;
18263         e_conv.inner = (void*)(e & (~1));
18264         e_conv.is_owned = (e & 1) || (e == 0);
18265         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18266         e_conv = DecodeError_clone(&e_conv);
18267         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18268         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
18269         return (int64_t)ret_conv;
18270 }
18271
18272 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18273         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
18274         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
18275         return ret_conv;
18276 }
18277
18278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18279         if ((_res & 1) != 0) return;
18280         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18281         CHECK_ACCESS(_res_ptr);
18282         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
18283         FREE((void*)_res);
18284         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
18285 }
18286
18287 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
18288         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18289         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
18290         return (int64_t)ret_conv;
18291 }
18292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18293         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
18294         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
18295         return ret_conv;
18296 }
18297
18298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18299         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
18300         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
18301         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
18302         return (int64_t)ret_conv;
18303 }
18304
18305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18306         LDKChannelCounterparty o_conv;
18307         o_conv.inner = (void*)(o & (~1));
18308         o_conv.is_owned = (o & 1) || (o == 0);
18309         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18310         o_conv = ChannelCounterparty_clone(&o_conv);
18311         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18312         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
18313         return (int64_t)ret_conv;
18314 }
18315
18316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18317         LDKDecodeError e_conv;
18318         e_conv.inner = (void*)(e & (~1));
18319         e_conv.is_owned = (e & 1) || (e == 0);
18320         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18321         e_conv = DecodeError_clone(&e_conv);
18322         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18323         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
18324         return (int64_t)ret_conv;
18325 }
18326
18327 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18328         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
18329         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
18330         return ret_conv;
18331 }
18332
18333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18334         if ((_res & 1) != 0) return;
18335         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18336         CHECK_ACCESS(_res_ptr);
18337         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
18338         FREE((void*)_res);
18339         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
18340 }
18341
18342 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
18343         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18344         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
18345         return (int64_t)ret_conv;
18346 }
18347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18348         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
18349         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
18350         return ret_conv;
18351 }
18352
18353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18354         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
18355         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
18356         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
18357         return (int64_t)ret_conv;
18358 }
18359
18360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18361         LDKChannelDetails o_conv;
18362         o_conv.inner = (void*)(o & (~1));
18363         o_conv.is_owned = (o & 1) || (o == 0);
18364         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18365         o_conv = ChannelDetails_clone(&o_conv);
18366         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18367         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
18368         return (int64_t)ret_conv;
18369 }
18370
18371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18372         LDKDecodeError e_conv;
18373         e_conv.inner = (void*)(e & (~1));
18374         e_conv.is_owned = (e & 1) || (e == 0);
18375         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18376         e_conv = DecodeError_clone(&e_conv);
18377         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18378         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
18379         return (int64_t)ret_conv;
18380 }
18381
18382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18383         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
18384         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
18385         return ret_conv;
18386 }
18387
18388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18389         if ((_res & 1) != 0) return;
18390         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18391         CHECK_ACCESS(_res_ptr);
18392         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
18393         FREE((void*)_res);
18394         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
18395 }
18396
18397 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
18398         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18399         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
18400         return (int64_t)ret_conv;
18401 }
18402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18403         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
18404         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
18405         return ret_conv;
18406 }
18407
18408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18409         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
18410         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
18411         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
18412         return (int64_t)ret_conv;
18413 }
18414
18415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18416         LDKPhantomRouteHints o_conv;
18417         o_conv.inner = (void*)(o & (~1));
18418         o_conv.is_owned = (o & 1) || (o == 0);
18419         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18420         o_conv = PhantomRouteHints_clone(&o_conv);
18421         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18422         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
18423         return (int64_t)ret_conv;
18424 }
18425
18426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18427         LDKDecodeError e_conv;
18428         e_conv.inner = (void*)(e & (~1));
18429         e_conv.is_owned = (e & 1) || (e == 0);
18430         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18431         e_conv = DecodeError_clone(&e_conv);
18432         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18433         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
18434         return (int64_t)ret_conv;
18435 }
18436
18437 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18438         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
18439         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
18440         return ret_conv;
18441 }
18442
18443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18444         if ((_res & 1) != 0) return;
18445         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18446         CHECK_ACCESS(_res_ptr);
18447         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
18448         FREE((void*)_res);
18449         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
18450 }
18451
18452 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
18453         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18454         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
18455         return (int64_t)ret_conv;
18456 }
18457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18458         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
18459         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
18460         return ret_conv;
18461 }
18462
18463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18464         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
18465         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
18466         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
18467         return (int64_t)ret_conv;
18468 }
18469
18470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18471         LDKCVec_ChannelMonitorZ _res_constr;
18472         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18473         if (_res_constr.datalen > 0)
18474                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
18475         else
18476                 _res_constr.data = NULL;
18477         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18478         for (size_t q = 0; q < _res_constr.datalen; q++) {
18479                 int64_t _res_conv_16 = _res_vals[q];
18480                 LDKChannelMonitor _res_conv_16_conv;
18481                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
18482                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
18483                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
18484                 _res_constr.data[q] = _res_conv_16_conv;
18485         }
18486         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18487         CVec_ChannelMonitorZ_free(_res_constr);
18488 }
18489
18490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
18491         LDKThirtyTwoBytes a_ref;
18492         CHECK((*env)->GetArrayLength(env, a) == 32);
18493         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18494         LDKChannelManager b_conv;
18495         b_conv.inner = (void*)(b & (~1));
18496         b_conv.is_owned = (b & 1) || (b == 0);
18497         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18498         // WARNING: we need a move here but no clone is available for LDKChannelManager
18499         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
18500         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
18501         return ((int64_t)ret_conv);
18502 }
18503
18504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18505         if ((_res & 1) != 0) return;
18506         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18507         CHECK_ACCESS(_res_ptr);
18508         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
18509         FREE((void*)_res);
18510         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
18511 }
18512
18513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18514         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18515         CHECK_ACCESS(o_ptr);
18516         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
18517         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
18518         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
18519         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
18520         return (int64_t)ret_conv;
18521 }
18522
18523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18524         LDKDecodeError e_conv;
18525         e_conv.inner = (void*)(e & (~1));
18526         e_conv.is_owned = (e & 1) || (e == 0);
18527         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18528         e_conv = DecodeError_clone(&e_conv);
18529         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
18530         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
18531         return (int64_t)ret_conv;
18532 }
18533
18534 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18535         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
18536         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
18537         return ret_conv;
18538 }
18539
18540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18541         if ((_res & 1) != 0) return;
18542         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18543         CHECK_ACCESS(_res_ptr);
18544         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
18545         FREE((void*)_res);
18546         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
18547 }
18548
18549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18550         LDKChannelConfig o_conv;
18551         o_conv.inner = (void*)(o & (~1));
18552         o_conv.is_owned = (o & 1) || (o == 0);
18553         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18554         o_conv = ChannelConfig_clone(&o_conv);
18555         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18556         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
18557         return (int64_t)ret_conv;
18558 }
18559
18560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18561         LDKDecodeError e_conv;
18562         e_conv.inner = (void*)(e & (~1));
18563         e_conv.is_owned = (e & 1) || (e == 0);
18564         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18565         e_conv = DecodeError_clone(&e_conv);
18566         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18567         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
18568         return (int64_t)ret_conv;
18569 }
18570
18571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18572         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
18573         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
18574         return ret_conv;
18575 }
18576
18577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18578         if ((_res & 1) != 0) return;
18579         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18580         CHECK_ACCESS(_res_ptr);
18581         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
18582         FREE((void*)_res);
18583         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
18584 }
18585
18586 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
18587         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18588         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
18589         return (int64_t)ret_conv;
18590 }
18591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18592         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
18593         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
18594         return ret_conv;
18595 }
18596
18597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18598         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
18599         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18600         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
18601         return (int64_t)ret_conv;
18602 }
18603
18604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18605         LDKOutPoint o_conv;
18606         o_conv.inner = (void*)(o & (~1));
18607         o_conv.is_owned = (o & 1) || (o == 0);
18608         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18609         o_conv = OutPoint_clone(&o_conv);
18610         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18611         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
18612         return (int64_t)ret_conv;
18613 }
18614
18615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18616         LDKDecodeError e_conv;
18617         e_conv.inner = (void*)(e & (~1));
18618         e_conv.is_owned = (e & 1) || (e == 0);
18619         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18620         e_conv = DecodeError_clone(&e_conv);
18621         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18622         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
18623         return (int64_t)ret_conv;
18624 }
18625
18626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18627         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
18628         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
18629         return ret_conv;
18630 }
18631
18632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18633         if ((_res & 1) != 0) return;
18634         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18635         CHECK_ACCESS(_res_ptr);
18636         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
18637         FREE((void*)_res);
18638         CResult_OutPointDecodeErrorZ_free(_res_conv);
18639 }
18640
18641 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
18642         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18643         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
18644         return (int64_t)ret_conv;
18645 }
18646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18647         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
18648         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
18649         return ret_conv;
18650 }
18651
18652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18653         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
18654         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
18655         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
18656         return (int64_t)ret_conv;
18657 }
18658
18659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18660         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18661         CHECK_ACCESS(o_ptr);
18662         LDKType o_conv = *(LDKType*)(o_ptr);
18663         if (o_conv.free == LDKType_JCalls_free) {
18664                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18665                 LDKType_JCalls_cloned(&o_conv);
18666         }
18667         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18668         *ret_copy = COption_TypeZ_some(o_conv);
18669         int64_t ret_ref = (uintptr_t)ret_copy;
18670         return ret_ref;
18671 }
18672
18673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
18674         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18675         *ret_copy = COption_TypeZ_none();
18676         int64_t ret_ref = (uintptr_t)ret_copy;
18677         return ret_ref;
18678 }
18679
18680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18681         if ((_res & 1) != 0) return;
18682         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18683         CHECK_ACCESS(_res_ptr);
18684         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
18685         FREE((void*)_res);
18686         COption_TypeZ_free(_res_conv);
18687 }
18688
18689 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
18690         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18691         *ret_copy = COption_TypeZ_clone(arg);
18692 int64_t ret_ref = (uintptr_t)ret_copy;
18693         return ret_ref;
18694 }
18695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18696         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
18697         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
18698         return ret_conv;
18699 }
18700
18701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18702         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
18703         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
18704         *ret_copy = COption_TypeZ_clone(orig_conv);
18705         int64_t ret_ref = (uintptr_t)ret_copy;
18706         return ret_ref;
18707 }
18708
18709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18710         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
18711         CHECK_ACCESS(o_ptr);
18712         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
18713         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
18714         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18715         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
18716         return (int64_t)ret_conv;
18717 }
18718
18719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18720         LDKDecodeError e_conv;
18721         e_conv.inner = (void*)(e & (~1));
18722         e_conv.is_owned = (e & 1) || (e == 0);
18723         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18724         e_conv = DecodeError_clone(&e_conv);
18725         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18726         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
18727         return (int64_t)ret_conv;
18728 }
18729
18730 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18731         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
18732         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
18733         return ret_conv;
18734 }
18735
18736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18737         if ((_res & 1) != 0) return;
18738         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18739         CHECK_ACCESS(_res_ptr);
18740         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
18741         FREE((void*)_res);
18742         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
18743 }
18744
18745 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
18746         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18747         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
18748         return (int64_t)ret_conv;
18749 }
18750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18751         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
18752         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
18753         return ret_conv;
18754 }
18755
18756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18757         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
18758         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
18759         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
18760         return (int64_t)ret_conv;
18761 }
18762
18763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
18764         LDKThirtyTwoBytes o_ref;
18765         CHECK((*env)->GetArrayLength(env, o) == 32);
18766         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
18767         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18768         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
18769         return (int64_t)ret_conv;
18770 }
18771
18772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18773         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18774         CHECK_ACCESS(e_ptr);
18775         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
18776         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
18777         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18778         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
18779         return (int64_t)ret_conv;
18780 }
18781
18782 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18783         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
18784         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
18785         return ret_conv;
18786 }
18787
18788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18789         if ((_res & 1) != 0) return;
18790         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18791         CHECK_ACCESS(_res_ptr);
18792         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
18793         FREE((void*)_res);
18794         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
18795 }
18796
18797 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
18798         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18799         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
18800         return (int64_t)ret_conv;
18801 }
18802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18803         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
18804         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
18805         return ret_conv;
18806 }
18807
18808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18809         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
18810         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
18811         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
18812         return (int64_t)ret_conv;
18813 }
18814
18815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
18816         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
18817         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18818         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
18819         return (int64_t)ret_conv;
18820 }
18821
18822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18823         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18824         CHECK_ACCESS(e_ptr);
18825         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
18826         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
18827         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18828         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
18829         return (int64_t)ret_conv;
18830 }
18831
18832 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18833         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
18834         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
18835         return ret_conv;
18836 }
18837
18838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18839         if ((_res & 1) != 0) return;
18840         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18841         CHECK_ACCESS(_res_ptr);
18842         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
18843         FREE((void*)_res);
18844         CResult_SiPrefixParseErrorZ_free(_res_conv);
18845 }
18846
18847 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
18848         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18849         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
18850         return (int64_t)ret_conv;
18851 }
18852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18853         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
18854         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
18855         return ret_conv;
18856 }
18857
18858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18859         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
18860         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
18861         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
18862         return (int64_t)ret_conv;
18863 }
18864
18865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18866         LDKInvoice o_conv;
18867         o_conv.inner = (void*)(o & (~1));
18868         o_conv.is_owned = (o & 1) || (o == 0);
18869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18870         o_conv = Invoice_clone(&o_conv);
18871         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18872         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
18873         return (int64_t)ret_conv;
18874 }
18875
18876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18877         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18878         CHECK_ACCESS(e_ptr);
18879         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
18880         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
18881         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18882         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
18883         return (int64_t)ret_conv;
18884 }
18885
18886 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18887         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
18888         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
18889         return ret_conv;
18890 }
18891
18892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18893         if ((_res & 1) != 0) return;
18894         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18895         CHECK_ACCESS(_res_ptr);
18896         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
18897         FREE((void*)_res);
18898         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
18899 }
18900
18901 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
18902         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18903         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
18904         return (int64_t)ret_conv;
18905 }
18906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18907         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
18908         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
18909         return ret_conv;
18910 }
18911
18912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18913         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
18914         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
18915         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
18916         return (int64_t)ret_conv;
18917 }
18918
18919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18920         LDKSignedRawInvoice o_conv;
18921         o_conv.inner = (void*)(o & (~1));
18922         o_conv.is_owned = (o & 1) || (o == 0);
18923         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18924         o_conv = SignedRawInvoice_clone(&o_conv);
18925         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18926         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
18927         return (int64_t)ret_conv;
18928 }
18929
18930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18931         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
18932         CHECK_ACCESS(e_ptr);
18933         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
18934         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
18935         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18936         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
18937         return (int64_t)ret_conv;
18938 }
18939
18940 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18941         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
18942         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
18943         return ret_conv;
18944 }
18945
18946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18947         if ((_res & 1) != 0) return;
18948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18949         CHECK_ACCESS(_res_ptr);
18950         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
18951         FREE((void*)_res);
18952         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
18953 }
18954
18955 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
18956         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18957         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
18958         return (int64_t)ret_conv;
18959 }
18960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18961         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
18962         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
18963         return ret_conv;
18964 }
18965
18966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18967         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
18968         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
18969         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
18970         return (int64_t)ret_conv;
18971 }
18972
18973 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
18974         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18975         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
18976         return ((int64_t)ret_conv);
18977 }
18978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18979         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
18980         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
18981         return ret_conv;
18982 }
18983
18984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18985         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
18986         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
18987         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
18988         return ((int64_t)ret_conv);
18989 }
18990
18991 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) {
18992         LDKRawInvoice a_conv;
18993         a_conv.inner = (void*)(a & (~1));
18994         a_conv.is_owned = (a & 1) || (a == 0);
18995         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18996         a_conv = RawInvoice_clone(&a_conv);
18997         LDKThirtyTwoBytes b_ref;
18998         CHECK((*env)->GetArrayLength(env, b) == 32);
18999         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
19000         LDKInvoiceSignature c_conv;
19001         c_conv.inner = (void*)(c & (~1));
19002         c_conv.is_owned = (c & 1) || (c == 0);
19003         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19004         c_conv = InvoiceSignature_clone(&c_conv);
19005         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
19006         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
19007         return ((int64_t)ret_conv);
19008 }
19009
19010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_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         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
19015         FREE((void*)_res);
19016         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
19017 }
19018
19019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19020         LDKPayeePubKey o_conv;
19021         o_conv.inner = (void*)(o & (~1));
19022         o_conv.is_owned = (o & 1) || (o == 0);
19023         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19024         o_conv = PayeePubKey_clone(&o_conv);
19025         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19026         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
19027         return (int64_t)ret_conv;
19028 }
19029
19030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19031         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
19032         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19033         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
19034         return (int64_t)ret_conv;
19035 }
19036
19037 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19038         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
19039         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
19040         return ret_conv;
19041 }
19042
19043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19044         if ((_res & 1) != 0) return;
19045         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19046         CHECK_ACCESS(_res_ptr);
19047         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
19048         FREE((void*)_res);
19049         CResult_PayeePubKeyErrorZ_free(_res_conv);
19050 }
19051
19052 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
19053         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19054         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
19055         return (int64_t)ret_conv;
19056 }
19057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19058         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
19059         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
19060         return ret_conv;
19061 }
19062
19063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19064         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
19065         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
19066         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
19067         return (int64_t)ret_conv;
19068 }
19069
19070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19071         LDKCVec_PrivateRouteZ _res_constr;
19072         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19073         if (_res_constr.datalen > 0)
19074                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
19075         else
19076                 _res_constr.data = NULL;
19077         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19078         for (size_t o = 0; o < _res_constr.datalen; o++) {
19079                 int64_t _res_conv_14 = _res_vals[o];
19080                 LDKPrivateRoute _res_conv_14_conv;
19081                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
19082                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
19083                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
19084                 _res_constr.data[o] = _res_conv_14_conv;
19085         }
19086         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19087         CVec_PrivateRouteZ_free(_res_constr);
19088 }
19089
19090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19091         LDKPositiveTimestamp o_conv;
19092         o_conv.inner = (void*)(o & (~1));
19093         o_conv.is_owned = (o & 1) || (o == 0);
19094         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19095         o_conv = PositiveTimestamp_clone(&o_conv);
19096         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19097         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
19098         return (int64_t)ret_conv;
19099 }
19100
19101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19102         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19103         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19104         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
19105         return (int64_t)ret_conv;
19106 }
19107
19108 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19109         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
19110         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
19111         return ret_conv;
19112 }
19113
19114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19115         if ((_res & 1) != 0) return;
19116         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19117         CHECK_ACCESS(_res_ptr);
19118         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
19119         FREE((void*)_res);
19120         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
19121 }
19122
19123 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
19124         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19125         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
19126         return (int64_t)ret_conv;
19127 }
19128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19129         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
19130         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
19131         return ret_conv;
19132 }
19133
19134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19135         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
19136         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
19137         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
19138         return (int64_t)ret_conv;
19139 }
19140
19141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
19142         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19143         *ret_conv = CResult_NoneSemanticErrorZ_ok();
19144         return (int64_t)ret_conv;
19145 }
19146
19147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19148         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
19149         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19150         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
19151         return (int64_t)ret_conv;
19152 }
19153
19154 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19155         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
19156         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
19157         return ret_conv;
19158 }
19159
19160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19161         if ((_res & 1) != 0) return;
19162         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19163         CHECK_ACCESS(_res_ptr);
19164         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
19165         FREE((void*)_res);
19166         CResult_NoneSemanticErrorZ_free(_res_conv);
19167 }
19168
19169 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
19170         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19171         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
19172         return (int64_t)ret_conv;
19173 }
19174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19175         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
19176         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
19177         return ret_conv;
19178 }
19179
19180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19181         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
19182         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
19183         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
19184         return (int64_t)ret_conv;
19185 }
19186
19187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19188         LDKInvoice o_conv;
19189         o_conv.inner = (void*)(o & (~1));
19190         o_conv.is_owned = (o & 1) || (o == 0);
19191         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19192         o_conv = Invoice_clone(&o_conv);
19193         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19194         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
19195         return (int64_t)ret_conv;
19196 }
19197
19198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19199         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
19200         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19201         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
19202         return (int64_t)ret_conv;
19203 }
19204
19205 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19206         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
19207         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
19208         return ret_conv;
19209 }
19210
19211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19212         if ((_res & 1) != 0) return;
19213         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19214         CHECK_ACCESS(_res_ptr);
19215         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
19216         FREE((void*)_res);
19217         CResult_InvoiceSemanticErrorZ_free(_res_conv);
19218 }
19219
19220 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
19221         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19222         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
19223         return (int64_t)ret_conv;
19224 }
19225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19226         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
19227         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
19228         return ret_conv;
19229 }
19230
19231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19232         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
19233         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
19234         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
19235         return (int64_t)ret_conv;
19236 }
19237
19238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19239         LDKDescription o_conv;
19240         o_conv.inner = (void*)(o & (~1));
19241         o_conv.is_owned = (o & 1) || (o == 0);
19242         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19243         o_conv = Description_clone(&o_conv);
19244         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19245         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
19246         return (int64_t)ret_conv;
19247 }
19248
19249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19250         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19251         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19252         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
19253         return (int64_t)ret_conv;
19254 }
19255
19256 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19257         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
19258         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
19259         return ret_conv;
19260 }
19261
19262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19263         if ((_res & 1) != 0) return;
19264         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19265         CHECK_ACCESS(_res_ptr);
19266         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
19267         FREE((void*)_res);
19268         CResult_DescriptionCreationErrorZ_free(_res_conv);
19269 }
19270
19271 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
19272         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19273         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
19274         return (int64_t)ret_conv;
19275 }
19276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19277         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
19278         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
19279         return ret_conv;
19280 }
19281
19282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19283         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
19284         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
19285         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
19286         return (int64_t)ret_conv;
19287 }
19288
19289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19290         LDKPrivateRoute o_conv;
19291         o_conv.inner = (void*)(o & (~1));
19292         o_conv.is_owned = (o & 1) || (o == 0);
19293         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19294         o_conv = PrivateRoute_clone(&o_conv);
19295         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19296         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
19297         return (int64_t)ret_conv;
19298 }
19299
19300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19301         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
19302         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19303         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
19304         return (int64_t)ret_conv;
19305 }
19306
19307 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19308         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
19309         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
19310         return ret_conv;
19311 }
19312
19313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19314         if ((_res & 1) != 0) return;
19315         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19316         CHECK_ACCESS(_res_ptr);
19317         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
19318         FREE((void*)_res);
19319         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
19320 }
19321
19322 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
19323         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19324         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
19325         return (int64_t)ret_conv;
19326 }
19327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19328         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
19329         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
19330         return ret_conv;
19331 }
19332
19333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19334         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
19335         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
19336         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
19337         return (int64_t)ret_conv;
19338 }
19339
19340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
19341         LDKStr o_conv = java_to_owned_str(env, o);
19342         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19343         *ret_conv = CResult_StringErrorZ_ok(o_conv);
19344         return (int64_t)ret_conv;
19345 }
19346
19347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19348         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
19349         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19350         *ret_conv = CResult_StringErrorZ_err(e_conv);
19351         return (int64_t)ret_conv;
19352 }
19353
19354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19355         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
19356         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
19357         return ret_conv;
19358 }
19359
19360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19361         if ((_res & 1) != 0) return;
19362         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19363         CHECK_ACCESS(_res_ptr);
19364         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
19365         FREE((void*)_res);
19366         CResult_StringErrorZ_free(_res_conv);
19367 }
19368
19369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19370         LDKChannelMonitorUpdate o_conv;
19371         o_conv.inner = (void*)(o & (~1));
19372         o_conv.is_owned = (o & 1) || (o == 0);
19373         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19374         o_conv = ChannelMonitorUpdate_clone(&o_conv);
19375         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19376         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
19377         return (int64_t)ret_conv;
19378 }
19379
19380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19381         LDKDecodeError e_conv;
19382         e_conv.inner = (void*)(e & (~1));
19383         e_conv.is_owned = (e & 1) || (e == 0);
19384         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19385         e_conv = DecodeError_clone(&e_conv);
19386         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19387         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
19388         return (int64_t)ret_conv;
19389 }
19390
19391 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19392         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
19393         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
19394         return ret_conv;
19395 }
19396
19397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19398         if ((_res & 1) != 0) return;
19399         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19400         CHECK_ACCESS(_res_ptr);
19401         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
19402         FREE((void*)_res);
19403         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
19404 }
19405
19406 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
19407         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19408         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
19409         return (int64_t)ret_conv;
19410 }
19411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19412         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
19413         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
19414         return ret_conv;
19415 }
19416
19417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19418         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
19419         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
19420         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
19421         return (int64_t)ret_conv;
19422 }
19423
19424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19425         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19426         CHECK_ACCESS(o_ptr);
19427         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
19428         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
19429         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19430         *ret_copy = COption_MonitorEventZ_some(o_conv);
19431         int64_t ret_ref = (uintptr_t)ret_copy;
19432         return ret_ref;
19433 }
19434
19435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
19436         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19437         *ret_copy = COption_MonitorEventZ_none();
19438         int64_t ret_ref = (uintptr_t)ret_copy;
19439         return ret_ref;
19440 }
19441
19442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19443         if ((_res & 1) != 0) return;
19444         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19445         CHECK_ACCESS(_res_ptr);
19446         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
19447         FREE((void*)_res);
19448         COption_MonitorEventZ_free(_res_conv);
19449 }
19450
19451 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
19452         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19453         *ret_copy = COption_MonitorEventZ_clone(arg);
19454 int64_t ret_ref = (uintptr_t)ret_copy;
19455         return ret_ref;
19456 }
19457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19458         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
19459         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
19460         return ret_conv;
19461 }
19462
19463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19464         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
19465         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
19466         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
19467         int64_t ret_ref = (uintptr_t)ret_copy;
19468         return ret_ref;
19469 }
19470
19471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19472         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19473         CHECK_ACCESS(o_ptr);
19474         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
19475         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
19476         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19477         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
19478         return (int64_t)ret_conv;
19479 }
19480
19481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19482         LDKDecodeError e_conv;
19483         e_conv.inner = (void*)(e & (~1));
19484         e_conv.is_owned = (e & 1) || (e == 0);
19485         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19486         e_conv = DecodeError_clone(&e_conv);
19487         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19488         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
19489         return (int64_t)ret_conv;
19490 }
19491
19492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19493         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
19494         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
19495         return ret_conv;
19496 }
19497
19498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19499         if ((_res & 1) != 0) return;
19500         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19501         CHECK_ACCESS(_res_ptr);
19502         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
19503         FREE((void*)_res);
19504         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
19505 }
19506
19507 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
19508         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19509         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
19510         return (int64_t)ret_conv;
19511 }
19512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19513         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
19514         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
19515         return ret_conv;
19516 }
19517
19518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19519         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
19520         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19521         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
19522         return (int64_t)ret_conv;
19523 }
19524
19525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19526         LDKHTLCUpdate o_conv;
19527         o_conv.inner = (void*)(o & (~1));
19528         o_conv.is_owned = (o & 1) || (o == 0);
19529         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19530         o_conv = HTLCUpdate_clone(&o_conv);
19531         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19532         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
19533         return (int64_t)ret_conv;
19534 }
19535
19536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19537         LDKDecodeError e_conv;
19538         e_conv.inner = (void*)(e & (~1));
19539         e_conv.is_owned = (e & 1) || (e == 0);
19540         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19541         e_conv = DecodeError_clone(&e_conv);
19542         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19543         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
19544         return (int64_t)ret_conv;
19545 }
19546
19547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19548         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
19549         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
19550         return ret_conv;
19551 }
19552
19553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19554         if ((_res & 1) != 0) return;
19555         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19556         CHECK_ACCESS(_res_ptr);
19557         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
19558         FREE((void*)_res);
19559         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
19560 }
19561
19562 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
19563         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19564         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
19565         return (int64_t)ret_conv;
19566 }
19567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19568         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
19569         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
19570         return ret_conv;
19571 }
19572
19573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19574         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
19575         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19576         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
19577         return (int64_t)ret_conv;
19578 }
19579
19580 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
19581         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19582         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
19583         return ((int64_t)ret_conv);
19584 }
19585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19586         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
19587         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
19588         return ret_conv;
19589 }
19590
19591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19592         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
19593         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19594         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
19595         return ((int64_t)ret_conv);
19596 }
19597
19598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
19599         LDKOutPoint a_conv;
19600         a_conv.inner = (void*)(a & (~1));
19601         a_conv.is_owned = (a & 1) || (a == 0);
19602         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19603         a_conv = OutPoint_clone(&a_conv);
19604         LDKCVec_u8Z b_ref;
19605         b_ref.datalen = (*env)->GetArrayLength(env, b);
19606         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
19607         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
19608         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19609         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
19610         return ((int64_t)ret_conv);
19611 }
19612
19613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19614         if ((_res & 1) != 0) return;
19615         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19616         CHECK_ACCESS(_res_ptr);
19617         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
19618         FREE((void*)_res);
19619         C2Tuple_OutPointScriptZ_free(_res_conv);
19620 }
19621
19622 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
19623         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19624         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
19625         return ((int64_t)ret_conv);
19626 }
19627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19628         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
19629         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
19630         return ret_conv;
19631 }
19632
19633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19634         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
19635         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19636         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
19637         return ((int64_t)ret_conv);
19638 }
19639
19640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
19641         LDKCVec_u8Z b_ref;
19642         b_ref.datalen = (*env)->GetArrayLength(env, b);
19643         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
19644         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
19645         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
19646         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
19647         return ((int64_t)ret_conv);
19648 }
19649
19650 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19651         if ((_res & 1) != 0) return;
19652         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19653         CHECK_ACCESS(_res_ptr);
19654         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
19655         FREE((void*)_res);
19656         C2Tuple_u32ScriptZ_free(_res_conv);
19657 }
19658
19659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19660         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
19661         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19662         if (_res_constr.datalen > 0)
19663                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
19664         else
19665                 _res_constr.data = NULL;
19666         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19667         for (size_t v = 0; v < _res_constr.datalen; v++) {
19668                 int64_t _res_conv_21 = _res_vals[v];
19669                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
19670                 CHECK_ACCESS(_res_conv_21_ptr);
19671                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
19672                 FREE((void*)_res_conv_21);
19673                 _res_constr.data[v] = _res_conv_21_conv;
19674         }
19675         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19676         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
19677 }
19678
19679 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
19680         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19681         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
19682         return ((int64_t)ret_conv);
19683 }
19684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19685         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
19686         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
19687         return ret_conv;
19688 }
19689
19690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19691         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
19692         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19693         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
19694         return ((int64_t)ret_conv);
19695 }
19696
19697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
19698         LDKThirtyTwoBytes a_ref;
19699         CHECK((*env)->GetArrayLength(env, a) == 32);
19700         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19701         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
19702         b_constr.datalen = (*env)->GetArrayLength(env, b);
19703         if (b_constr.datalen > 0)
19704                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
19705         else
19706                 b_constr.data = NULL;
19707         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
19708         for (size_t v = 0; v < b_constr.datalen; v++) {
19709                 int64_t b_conv_21 = b_vals[v];
19710                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
19711                 CHECK_ACCESS(b_conv_21_ptr);
19712                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
19713                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
19714                 b_constr.data[v] = b_conv_21_conv;
19715         }
19716         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
19717         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19718         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
19719         return ((int64_t)ret_conv);
19720 }
19721
19722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19723         if ((_res & 1) != 0) return;
19724         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19725         CHECK_ACCESS(_res_ptr);
19726         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
19727         FREE((void*)_res);
19728         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
19729 }
19730
19731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19732         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
19733         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19734         if (_res_constr.datalen > 0)
19735                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
19736         else
19737                 _res_constr.data = NULL;
19738         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19739         for (size_t o = 0; o < _res_constr.datalen; o++) {
19740                 int64_t _res_conv_40 = _res_vals[o];
19741                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
19742                 CHECK_ACCESS(_res_conv_40_ptr);
19743                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
19744                 FREE((void*)_res_conv_40);
19745                 _res_constr.data[o] = _res_conv_40_conv;
19746         }
19747         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19748         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
19749 }
19750
19751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19752         LDKCVec_EventZ _res_constr;
19753         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19754         if (_res_constr.datalen > 0)
19755                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
19756         else
19757                 _res_constr.data = NULL;
19758         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19759         for (size_t h = 0; h < _res_constr.datalen; h++) {
19760                 int64_t _res_conv_7 = _res_vals[h];
19761                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
19762                 CHECK_ACCESS(_res_conv_7_ptr);
19763                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
19764                 FREE((void*)_res_conv_7);
19765                 _res_constr.data[h] = _res_conv_7_conv;
19766         }
19767         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19768         CVec_EventZ_free(_res_constr);
19769 }
19770
19771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19772         LDKCVec_TransactionZ _res_constr;
19773         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19774         if (_res_constr.datalen > 0)
19775                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
19776         else
19777                 _res_constr.data = NULL;
19778         for (size_t i = 0; i < _res_constr.datalen; i++) {
19779                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19780                 LDKTransaction _res_conv_8_ref;
19781                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
19782                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
19783                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
19784                 _res_conv_8_ref.data_is_owned = true;
19785                 _res_constr.data[i] = _res_conv_8_ref;
19786         }
19787         CVec_TransactionZ_free(_res_constr);
19788 }
19789
19790 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
19791         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19792         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
19793         return ((int64_t)ret_conv);
19794 }
19795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19796         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
19797         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
19798         return ret_conv;
19799 }
19800
19801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19802         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
19803         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19804         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
19805         return ((int64_t)ret_conv);
19806 }
19807
19808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
19809         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
19810         CHECK_ACCESS(b_ptr);
19811         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
19812         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
19813         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
19814         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
19815         return ((int64_t)ret_conv);
19816 }
19817
19818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19819         if ((_res & 1) != 0) return;
19820         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19821         CHECK_ACCESS(_res_ptr);
19822         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
19823         FREE((void*)_res);
19824         C2Tuple_u32TxOutZ_free(_res_conv);
19825 }
19826
19827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19828         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
19829         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19830         if (_res_constr.datalen > 0)
19831                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
19832         else
19833                 _res_constr.data = NULL;
19834         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19835         for (size_t u = 0; u < _res_constr.datalen; u++) {
19836                 int64_t _res_conv_20 = _res_vals[u];
19837                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
19838                 CHECK_ACCESS(_res_conv_20_ptr);
19839                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
19840                 FREE((void*)_res_conv_20);
19841                 _res_constr.data[u] = _res_conv_20_conv;
19842         }
19843         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19844         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
19845 }
19846
19847 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
19848         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19849         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
19850         return ((int64_t)ret_conv);
19851 }
19852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19853         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
19854         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
19855         return ret_conv;
19856 }
19857
19858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19859         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
19860         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19861         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
19862         return ((int64_t)ret_conv);
19863 }
19864
19865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
19866         LDKThirtyTwoBytes a_ref;
19867         CHECK((*env)->GetArrayLength(env, a) == 32);
19868         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19869         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
19870         b_constr.datalen = (*env)->GetArrayLength(env, b);
19871         if (b_constr.datalen > 0)
19872                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
19873         else
19874                 b_constr.data = NULL;
19875         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
19876         for (size_t u = 0; u < b_constr.datalen; u++) {
19877                 int64_t b_conv_20 = b_vals[u];
19878                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
19879                 CHECK_ACCESS(b_conv_20_ptr);
19880                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
19881                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
19882                 b_constr.data[u] = b_conv_20_conv;
19883         }
19884         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
19885         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19886         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
19887         return ((int64_t)ret_conv);
19888 }
19889
19890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19891         if ((_res & 1) != 0) return;
19892         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19893         CHECK_ACCESS(_res_ptr);
19894         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
19895         FREE((void*)_res);
19896         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
19897 }
19898
19899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19900         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
19901         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19902         if (_res_constr.datalen > 0)
19903                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
19904         else
19905                 _res_constr.data = NULL;
19906         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19907         for (size_t n = 0; n < _res_constr.datalen; n++) {
19908                 int64_t _res_conv_39 = _res_vals[n];
19909                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
19910                 CHECK_ACCESS(_res_conv_39_ptr);
19911                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
19912                 FREE((void*)_res_conv_39);
19913                 _res_constr.data[n] = _res_conv_39_conv;
19914         }
19915         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19916         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
19917 }
19918
19919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19920         LDKCVec_BalanceZ _res_constr;
19921         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19922         if (_res_constr.datalen > 0)
19923                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
19924         else
19925                 _res_constr.data = NULL;
19926         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19927         for (size_t j = 0; j < _res_constr.datalen; j++) {
19928                 int64_t _res_conv_9 = _res_vals[j];
19929                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
19930                 CHECK_ACCESS(_res_conv_9_ptr);
19931                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
19932                 FREE((void*)_res_conv_9);
19933                 _res_constr.data[j] = _res_conv_9_conv;
19934         }
19935         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19936         CVec_BalanceZ_free(_res_constr);
19937 }
19938
19939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19940         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19941         CHECK_ACCESS(o_ptr);
19942         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
19943         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
19944         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19945         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
19946         return (int64_t)ret_conv;
19947 }
19948
19949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19950         LDKDecodeError e_conv;
19951         e_conv.inner = (void*)(e & (~1));
19952         e_conv.is_owned = (e & 1) || (e == 0);
19953         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19954         e_conv = DecodeError_clone(&e_conv);
19955         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19956         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
19957         return (int64_t)ret_conv;
19958 }
19959
19960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19961         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
19962         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
19963         return ret_conv;
19964 }
19965
19966 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19967         if ((_res & 1) != 0) return;
19968         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19969         CHECK_ACCESS(_res_ptr);
19970         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
19971         FREE((void*)_res);
19972         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
19973 }
19974
19975 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
19976         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19977         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
19978         return (int64_t)ret_conv;
19979 }
19980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19981         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
19982         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
19983         return ret_conv;
19984 }
19985
19986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19987         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
19988         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19989         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
19990         return (int64_t)ret_conv;
19991 }
19992
19993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
19994         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19995         *ret_conv = CResult_NoneLightningErrorZ_ok();
19996         return (int64_t)ret_conv;
19997 }
19998
19999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20000         LDKLightningError e_conv;
20001         e_conv.inner = (void*)(e & (~1));
20002         e_conv.is_owned = (e & 1) || (e == 0);
20003         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20004         e_conv = LightningError_clone(&e_conv);
20005         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20006         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
20007         return (int64_t)ret_conv;
20008 }
20009
20010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20011         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
20012         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
20013         return ret_conv;
20014 }
20015
20016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20017         if ((_res & 1) != 0) return;
20018         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20019         CHECK_ACCESS(_res_ptr);
20020         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
20021         FREE((void*)_res);
20022         CResult_NoneLightningErrorZ_free(_res_conv);
20023 }
20024
20025 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
20026         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20027         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
20028         return (int64_t)ret_conv;
20029 }
20030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20031         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
20032         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
20033         return ret_conv;
20034 }
20035
20036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20037         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
20038         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
20039         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
20040         return (int64_t)ret_conv;
20041 }
20042
20043 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
20044         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
20045         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
20046         return ((int64_t)ret_conv);
20047 }
20048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20049         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
20050         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
20051         return ret_conv;
20052 }
20053
20054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20055         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
20056         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
20057         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
20058         return ((int64_t)ret_conv);
20059 }
20060
20061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20062         LDKPublicKey a_ref;
20063         CHECK((*env)->GetArrayLength(env, a) == 33);
20064         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
20065         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
20066         CHECK_ACCESS(b_ptr);
20067         LDKType b_conv = *(LDKType*)(b_ptr);
20068         if (b_conv.free == LDKType_JCalls_free) {
20069                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20070                 LDKType_JCalls_cloned(&b_conv);
20071         }
20072         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
20073         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
20074         return ((int64_t)ret_conv);
20075 }
20076
20077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20078         if ((_res & 1) != 0) return;
20079         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20080         CHECK_ACCESS(_res_ptr);
20081         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
20082         FREE((void*)_res);
20083         C2Tuple_PublicKeyTypeZ_free(_res_conv);
20084 }
20085
20086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20087         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
20088         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20089         if (_res_constr.datalen > 0)
20090                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
20091         else
20092                 _res_constr.data = NULL;
20093         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20094         for (size_t z = 0; z < _res_constr.datalen; z++) {
20095                 int64_t _res_conv_25 = _res_vals[z];
20096                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
20097                 CHECK_ACCESS(_res_conv_25_ptr);
20098                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
20099                 FREE((void*)_res_conv_25);
20100                 _res_constr.data[z] = _res_conv_25_conv;
20101         }
20102         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20103         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
20104 }
20105
20106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
20107         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20108         *ret_conv = CResult_boolLightningErrorZ_ok(o);
20109         return (int64_t)ret_conv;
20110 }
20111
20112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20113         LDKLightningError e_conv;
20114         e_conv.inner = (void*)(e & (~1));
20115         e_conv.is_owned = (e & 1) || (e == 0);
20116         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20117         e_conv = LightningError_clone(&e_conv);
20118         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20119         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
20120         return (int64_t)ret_conv;
20121 }
20122
20123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20124         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
20125         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
20126         return ret_conv;
20127 }
20128
20129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20130         if ((_res & 1) != 0) return;
20131         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20132         CHECK_ACCESS(_res_ptr);
20133         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
20134         FREE((void*)_res);
20135         CResult_boolLightningErrorZ_free(_res_conv);
20136 }
20137
20138 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
20139         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20140         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
20141         return (int64_t)ret_conv;
20142 }
20143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20144         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
20145         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
20146         return ret_conv;
20147 }
20148
20149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20150         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
20151         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
20152         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
20153         return (int64_t)ret_conv;
20154 }
20155
20156 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
20157         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
20158         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
20159         return ((int64_t)ret_conv);
20160 }
20161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20162         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
20163         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
20164         return ret_conv;
20165 }
20166
20167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20168         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
20169         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
20170         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
20171         return ((int64_t)ret_conv);
20172 }
20173
20174 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) {
20175         LDKChannelAnnouncement a_conv;
20176         a_conv.inner = (void*)(a & (~1));
20177         a_conv.is_owned = (a & 1) || (a == 0);
20178         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20179         a_conv = ChannelAnnouncement_clone(&a_conv);
20180         LDKChannelUpdate b_conv;
20181         b_conv.inner = (void*)(b & (~1));
20182         b_conv.is_owned = (b & 1) || (b == 0);
20183         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20184         b_conv = ChannelUpdate_clone(&b_conv);
20185         LDKChannelUpdate c_conv;
20186         c_conv.inner = (void*)(c & (~1));
20187         c_conv.is_owned = (c & 1) || (c == 0);
20188         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
20189         c_conv = ChannelUpdate_clone(&c_conv);
20190         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
20191         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
20192         return ((int64_t)ret_conv);
20193 }
20194
20195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20196         if ((_res & 1) != 0) return;
20197         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20198         CHECK_ACCESS(_res_ptr);
20199         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
20200         FREE((void*)_res);
20201         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
20202 }
20203
20204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20205         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
20206         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20207         if (_res_constr.datalen > 0)
20208                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
20209         else
20210                 _res_constr.data = NULL;
20211         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20212         for (size_t h = 0; h < _res_constr.datalen; h++) {
20213                 int64_t _res_conv_59 = _res_vals[h];
20214                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
20215                 CHECK_ACCESS(_res_conv_59_ptr);
20216                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
20217                 FREE((void*)_res_conv_59);
20218                 _res_constr.data[h] = _res_conv_59_conv;
20219         }
20220         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20221         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
20222 }
20223
20224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20225         LDKCVec_NodeAnnouncementZ _res_constr;
20226         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20227         if (_res_constr.datalen > 0)
20228                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
20229         else
20230                 _res_constr.data = NULL;
20231         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20232         for (size_t s = 0; s < _res_constr.datalen; s++) {
20233                 int64_t _res_conv_18 = _res_vals[s];
20234                 LDKNodeAnnouncement _res_conv_18_conv;
20235                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
20236                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
20237                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
20238                 _res_constr.data[s] = _res_conv_18_conv;
20239         }
20240         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20241         CVec_NodeAnnouncementZ_free(_res_constr);
20242 }
20243
20244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20245         LDKCVec_PublicKeyZ _res_constr;
20246         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20247         if (_res_constr.datalen > 0)
20248                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
20249         else
20250                 _res_constr.data = NULL;
20251         for (size_t i = 0; i < _res_constr.datalen; i++) {
20252                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20253                 LDKPublicKey _res_conv_8_ref;
20254                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
20255                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
20256                 _res_constr.data[i] = _res_conv_8_ref;
20257         }
20258         CVec_PublicKeyZ_free(_res_constr);
20259 }
20260
20261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20262         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20263         CHECK_ACCESS(o_ptr);
20264         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
20265         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
20266         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20267         *ret_copy = COption_NetAddressZ_some(o_conv);
20268         int64_t ret_ref = (uintptr_t)ret_copy;
20269         return ret_ref;
20270 }
20271
20272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
20273         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20274         *ret_copy = COption_NetAddressZ_none();
20275         int64_t ret_ref = (uintptr_t)ret_copy;
20276         return ret_ref;
20277 }
20278
20279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20280         if ((_res & 1) != 0) return;
20281         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20282         CHECK_ACCESS(_res_ptr);
20283         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
20284         FREE((void*)_res);
20285         COption_NetAddressZ_free(_res_conv);
20286 }
20287
20288 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
20289         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20290         *ret_copy = COption_NetAddressZ_clone(arg);
20291 int64_t ret_ref = (uintptr_t)ret_copy;
20292         return ret_ref;
20293 }
20294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20295         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
20296         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
20297         return ret_conv;
20298 }
20299
20300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20301         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
20302         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
20303         *ret_copy = COption_NetAddressZ_clone(orig_conv);
20304         int64_t ret_ref = (uintptr_t)ret_copy;
20305         return ret_ref;
20306 }
20307
20308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20309         LDKCVec_u8Z o_ref;
20310         o_ref.datalen = (*env)->GetArrayLength(env, o);
20311         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
20312         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
20313         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20314         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
20315         return (int64_t)ret_conv;
20316 }
20317
20318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20319         LDKPeerHandleError e_conv;
20320         e_conv.inner = (void*)(e & (~1));
20321         e_conv.is_owned = (e & 1) || (e == 0);
20322         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20323         e_conv = PeerHandleError_clone(&e_conv);
20324         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20325         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
20326         return (int64_t)ret_conv;
20327 }
20328
20329 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20330         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
20331         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
20332         return ret_conv;
20333 }
20334
20335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20336         if ((_res & 1) != 0) return;
20337         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20338         CHECK_ACCESS(_res_ptr);
20339         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
20340         FREE((void*)_res);
20341         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
20342 }
20343
20344 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
20345         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20346         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
20347         return (int64_t)ret_conv;
20348 }
20349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20350         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
20351         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
20352         return ret_conv;
20353 }
20354
20355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20356         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
20357         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
20358         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
20359         return (int64_t)ret_conv;
20360 }
20361
20362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
20363         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20364         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
20365         return (int64_t)ret_conv;
20366 }
20367
20368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20369         LDKPeerHandleError e_conv;
20370         e_conv.inner = (void*)(e & (~1));
20371         e_conv.is_owned = (e & 1) || (e == 0);
20372         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20373         e_conv = PeerHandleError_clone(&e_conv);
20374         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20375         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
20376         return (int64_t)ret_conv;
20377 }
20378
20379 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20380         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
20381         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
20382         return ret_conv;
20383 }
20384
20385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20386         if ((_res & 1) != 0) return;
20387         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20388         CHECK_ACCESS(_res_ptr);
20389         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
20390         FREE((void*)_res);
20391         CResult_NonePeerHandleErrorZ_free(_res_conv);
20392 }
20393
20394 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
20395         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20396         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
20397         return (int64_t)ret_conv;
20398 }
20399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20400         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
20401         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
20402         return ret_conv;
20403 }
20404
20405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20406         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
20407         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
20408         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
20409         return (int64_t)ret_conv;
20410 }
20411
20412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
20413         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20414         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
20415         return (int64_t)ret_conv;
20416 }
20417
20418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20419         LDKPeerHandleError e_conv;
20420         e_conv.inner = (void*)(e & (~1));
20421         e_conv.is_owned = (e & 1) || (e == 0);
20422         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20423         e_conv = PeerHandleError_clone(&e_conv);
20424         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20425         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
20426         return (int64_t)ret_conv;
20427 }
20428
20429 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20430         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
20431         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
20432         return ret_conv;
20433 }
20434
20435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20436         if ((_res & 1) != 0) return;
20437         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20438         CHECK_ACCESS(_res_ptr);
20439         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
20440         FREE((void*)_res);
20441         CResult_boolPeerHandleErrorZ_free(_res_conv);
20442 }
20443
20444 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
20445         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20446         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
20447         return (int64_t)ret_conv;
20448 }
20449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20450         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
20451         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
20452         return ret_conv;
20453 }
20454
20455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20456         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
20457         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
20458         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
20459         return (int64_t)ret_conv;
20460 }
20461
20462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20463         LDKNodeId o_conv;
20464         o_conv.inner = (void*)(o & (~1));
20465         o_conv.is_owned = (o & 1) || (o == 0);
20466         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20467         o_conv = NodeId_clone(&o_conv);
20468         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20469         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
20470         return (int64_t)ret_conv;
20471 }
20472
20473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20474         LDKDecodeError e_conv;
20475         e_conv.inner = (void*)(e & (~1));
20476         e_conv.is_owned = (e & 1) || (e == 0);
20477         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20478         e_conv = DecodeError_clone(&e_conv);
20479         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20480         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
20481         return (int64_t)ret_conv;
20482 }
20483
20484 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20485         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
20486         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
20487         return ret_conv;
20488 }
20489
20490 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20491         if ((_res & 1) != 0) return;
20492         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20493         CHECK_ACCESS(_res_ptr);
20494         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
20495         FREE((void*)_res);
20496         CResult_NodeIdDecodeErrorZ_free(_res_conv);
20497 }
20498
20499 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
20500         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20501         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
20502         return (int64_t)ret_conv;
20503 }
20504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20505         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
20506         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
20507         return ret_conv;
20508 }
20509
20510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20511         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
20512         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
20513         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
20514         return (int64_t)ret_conv;
20515 }
20516
20517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20518         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20519         CHECK_ACCESS(o_ptr);
20520         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
20521         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
20522         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20523         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
20524         return (int64_t)ret_conv;
20525 }
20526
20527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20528         LDKDecodeError e_conv;
20529         e_conv.inner = (void*)(e & (~1));
20530         e_conv.is_owned = (e & 1) || (e == 0);
20531         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20532         e_conv = DecodeError_clone(&e_conv);
20533         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20534         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
20535         return (int64_t)ret_conv;
20536 }
20537
20538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20539         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
20540         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
20541         return ret_conv;
20542 }
20543
20544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20545         if ((_res & 1) != 0) return;
20546         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20547         CHECK_ACCESS(_res_ptr);
20548         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
20549         FREE((void*)_res);
20550         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
20551 }
20552
20553 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
20554         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20555         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
20556         return (int64_t)ret_conv;
20557 }
20558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20559         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
20560         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
20561         return ret_conv;
20562 }
20563
20564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20565         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
20566         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
20567         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
20568         return (int64_t)ret_conv;
20569 }
20570
20571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20572         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
20573         CHECK_ACCESS(o_ptr);
20574         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
20575         if (o_conv.free == LDKAccess_JCalls_free) {
20576                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20577                 LDKAccess_JCalls_cloned(&o_conv);
20578         }
20579         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
20580         *ret_copy = COption_AccessZ_some(o_conv);
20581         int64_t ret_ref = (uintptr_t)ret_copy;
20582         return ret_ref;
20583 }
20584
20585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
20586         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
20587         *ret_copy = COption_AccessZ_none();
20588         int64_t ret_ref = (uintptr_t)ret_copy;
20589         return ret_ref;
20590 }
20591
20592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20593         if ((_res & 1) != 0) return;
20594         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20595         CHECK_ACCESS(_res_ptr);
20596         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
20597         FREE((void*)_res);
20598         COption_AccessZ_free(_res_conv);
20599 }
20600
20601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20602         LDKChannelUpdateInfo o_conv;
20603         o_conv.inner = (void*)(o & (~1));
20604         o_conv.is_owned = (o & 1) || (o == 0);
20605         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20606         o_conv = ChannelUpdateInfo_clone(&o_conv);
20607         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20608         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
20609         return (int64_t)ret_conv;
20610 }
20611
20612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20613         LDKDecodeError e_conv;
20614         e_conv.inner = (void*)(e & (~1));
20615         e_conv.is_owned = (e & 1) || (e == 0);
20616         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20617         e_conv = DecodeError_clone(&e_conv);
20618         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20619         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
20620         return (int64_t)ret_conv;
20621 }
20622
20623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20624         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
20625         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
20626         return ret_conv;
20627 }
20628
20629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20630         if ((_res & 1) != 0) return;
20631         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20632         CHECK_ACCESS(_res_ptr);
20633         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
20634         FREE((void*)_res);
20635         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
20636 }
20637
20638 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
20639         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20640         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
20641         return (int64_t)ret_conv;
20642 }
20643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20644         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
20645         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
20646         return ret_conv;
20647 }
20648
20649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20650         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
20651         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
20652         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
20653         return (int64_t)ret_conv;
20654 }
20655
20656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20657         LDKChannelInfo o_conv;
20658         o_conv.inner = (void*)(o & (~1));
20659         o_conv.is_owned = (o & 1) || (o == 0);
20660         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20661         o_conv = ChannelInfo_clone(&o_conv);
20662         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20663         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
20664         return (int64_t)ret_conv;
20665 }
20666
20667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20668         LDKDecodeError e_conv;
20669         e_conv.inner = (void*)(e & (~1));
20670         e_conv.is_owned = (e & 1) || (e == 0);
20671         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20672         e_conv = DecodeError_clone(&e_conv);
20673         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20674         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
20675         return (int64_t)ret_conv;
20676 }
20677
20678 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20679         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
20680         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
20681         return ret_conv;
20682 }
20683
20684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20685         if ((_res & 1) != 0) return;
20686         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20687         CHECK_ACCESS(_res_ptr);
20688         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
20689         FREE((void*)_res);
20690         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
20691 }
20692
20693 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
20694         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20695         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
20696         return (int64_t)ret_conv;
20697 }
20698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20699         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
20700         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
20701         return ret_conv;
20702 }
20703
20704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20705         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
20706         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
20707         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
20708         return (int64_t)ret_conv;
20709 }
20710
20711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20712         LDKRoutingFees o_conv;
20713         o_conv.inner = (void*)(o & (~1));
20714         o_conv.is_owned = (o & 1) || (o == 0);
20715         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20716         o_conv = RoutingFees_clone(&o_conv);
20717         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20718         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
20719         return (int64_t)ret_conv;
20720 }
20721
20722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20723         LDKDecodeError e_conv;
20724         e_conv.inner = (void*)(e & (~1));
20725         e_conv.is_owned = (e & 1) || (e == 0);
20726         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20727         e_conv = DecodeError_clone(&e_conv);
20728         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20729         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
20730         return (int64_t)ret_conv;
20731 }
20732
20733 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20734         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
20735         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
20736         return ret_conv;
20737 }
20738
20739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20740         if ((_res & 1) != 0) return;
20741         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20742         CHECK_ACCESS(_res_ptr);
20743         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
20744         FREE((void*)_res);
20745         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
20746 }
20747
20748 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
20749         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20750         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
20751         return (int64_t)ret_conv;
20752 }
20753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20754         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
20755         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
20756         return ret_conv;
20757 }
20758
20759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20760         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
20761         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
20762         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
20763         return (int64_t)ret_conv;
20764 }
20765
20766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20767         LDKNodeAnnouncementInfo o_conv;
20768         o_conv.inner = (void*)(o & (~1));
20769         o_conv.is_owned = (o & 1) || (o == 0);
20770         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20771         o_conv = NodeAnnouncementInfo_clone(&o_conv);
20772         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20773         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
20774         return (int64_t)ret_conv;
20775 }
20776
20777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20778         LDKDecodeError e_conv;
20779         e_conv.inner = (void*)(e & (~1));
20780         e_conv.is_owned = (e & 1) || (e == 0);
20781         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20782         e_conv = DecodeError_clone(&e_conv);
20783         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20784         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
20785         return (int64_t)ret_conv;
20786 }
20787
20788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20789         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
20790         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
20791         return ret_conv;
20792 }
20793
20794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20795         if ((_res & 1) != 0) return;
20796         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20797         CHECK_ACCESS(_res_ptr);
20798         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
20799         FREE((void*)_res);
20800         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
20801 }
20802
20803 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
20804         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20805         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
20806         return (int64_t)ret_conv;
20807 }
20808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20809         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
20810         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
20811         return ret_conv;
20812 }
20813
20814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20815         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
20816         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20817         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
20818         return (int64_t)ret_conv;
20819 }
20820
20821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20822         LDKCVec_u64Z _res_constr;
20823         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20824         if (_res_constr.datalen > 0)
20825                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
20826         else
20827                 _res_constr.data = NULL;
20828         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20829         for (size_t g = 0; g < _res_constr.datalen; g++) {
20830                 int64_t _res_conv_6 = _res_vals[g];
20831                 _res_constr.data[g] = _res_conv_6;
20832         }
20833         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20834         CVec_u64Z_free(_res_constr);
20835 }
20836
20837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20838         LDKNodeInfo o_conv;
20839         o_conv.inner = (void*)(o & (~1));
20840         o_conv.is_owned = (o & 1) || (o == 0);
20841         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20842         o_conv = NodeInfo_clone(&o_conv);
20843         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20844         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
20845         return (int64_t)ret_conv;
20846 }
20847
20848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20849         LDKDecodeError e_conv;
20850         e_conv.inner = (void*)(e & (~1));
20851         e_conv.is_owned = (e & 1) || (e == 0);
20852         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20853         e_conv = DecodeError_clone(&e_conv);
20854         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20855         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
20856         return (int64_t)ret_conv;
20857 }
20858
20859 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20860         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
20861         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
20862         return ret_conv;
20863 }
20864
20865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20866         if ((_res & 1) != 0) return;
20867         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20868         CHECK_ACCESS(_res_ptr);
20869         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
20870         FREE((void*)_res);
20871         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
20872 }
20873
20874 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
20875         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20876         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
20877         return (int64_t)ret_conv;
20878 }
20879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20880         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
20881         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
20882         return ret_conv;
20883 }
20884
20885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20886         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
20887         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20888         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
20889         return (int64_t)ret_conv;
20890 }
20891
20892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20893         LDKNetworkGraph o_conv;
20894         o_conv.inner = (void*)(o & (~1));
20895         o_conv.is_owned = (o & 1) || (o == 0);
20896         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20897         o_conv = NetworkGraph_clone(&o_conv);
20898         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20899         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
20900         return (int64_t)ret_conv;
20901 }
20902
20903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20904         LDKDecodeError e_conv;
20905         e_conv.inner = (void*)(e & (~1));
20906         e_conv.is_owned = (e & 1) || (e == 0);
20907         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20908         e_conv = DecodeError_clone(&e_conv);
20909         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20910         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
20911         return (int64_t)ret_conv;
20912 }
20913
20914 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20915         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
20916         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
20917         return ret_conv;
20918 }
20919
20920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20921         if ((_res & 1) != 0) return;
20922         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20923         CHECK_ACCESS(_res_ptr);
20924         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
20925         FREE((void*)_res);
20926         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
20927 }
20928
20929 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
20930         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20931         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
20932         return (int64_t)ret_conv;
20933 }
20934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20935         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
20936         int64_t ret_conv = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
20937         return ret_conv;
20938 }
20939
20940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20941         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
20942         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20943         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
20944         return (int64_t)ret_conv;
20945 }
20946
20947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
20948         LDKCVec_NetAddressZ o_constr;
20949         o_constr.datalen = (*env)->GetArrayLength(env, o);
20950         if (o_constr.datalen > 0)
20951                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
20952         else
20953                 o_constr.data = NULL;
20954         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20955         for (size_t m = 0; m < o_constr.datalen; m++) {
20956                 int64_t o_conv_12 = o_vals[m];
20957                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
20958                 CHECK_ACCESS(o_conv_12_ptr);
20959                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
20960                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
20961                 o_constr.data[m] = o_conv_12_conv;
20962         }
20963         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20964         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20965         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
20966         int64_t ret_ref = (uintptr_t)ret_copy;
20967         return ret_ref;
20968 }
20969
20970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
20971         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20972         *ret_copy = COption_CVec_NetAddressZZ_none();
20973         int64_t ret_ref = (uintptr_t)ret_copy;
20974         return ret_ref;
20975 }
20976
20977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20978         if ((_res & 1) != 0) return;
20979         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
20980         CHECK_ACCESS(_res_ptr);
20981         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
20982         FREE((void*)_res);
20983         COption_CVec_NetAddressZZ_free(_res_conv);
20984 }
20985
20986 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
20987         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
20988         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
20989 int64_t ret_ref = (uintptr_t)ret_copy;
20990         return ret_ref;
20991 }
20992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20993         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
20994         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
20995         return ret_conv;
20996 }
20997
20998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20999         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
21000         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
21001         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
21002         int64_t ret_ref = (uintptr_t)ret_copy;
21003         return ret_ref;
21004 }
21005
21006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21007         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
21008         CHECK_ACCESS(o_ptr);
21009         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
21010         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
21011         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21012         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
21013         return (int64_t)ret_conv;
21014 }
21015
21016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21017         LDKDecodeError e_conv;
21018         e_conv.inner = (void*)(e & (~1));
21019         e_conv.is_owned = (e & 1) || (e == 0);
21020         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21021         e_conv = DecodeError_clone(&e_conv);
21022         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21023         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
21024         return (int64_t)ret_conv;
21025 }
21026
21027 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21028         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
21029         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
21030         return ret_conv;
21031 }
21032
21033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21034         if ((_res & 1) != 0) return;
21035         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21036         CHECK_ACCESS(_res_ptr);
21037         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
21038         FREE((void*)_res);
21039         CResult_NetAddressDecodeErrorZ_free(_res_conv);
21040 }
21041
21042 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
21043         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21044         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
21045         return (int64_t)ret_conv;
21046 }
21047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21048         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
21049         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
21050         return ret_conv;
21051 }
21052
21053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21054         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
21055         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
21056         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
21057         return (int64_t)ret_conv;
21058 }
21059
21060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21061         LDKCVec_UpdateAddHTLCZ _res_constr;
21062         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21063         if (_res_constr.datalen > 0)
21064                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
21065         else
21066                 _res_constr.data = NULL;
21067         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21068         for (size_t p = 0; p < _res_constr.datalen; p++) {
21069                 int64_t _res_conv_15 = _res_vals[p];
21070                 LDKUpdateAddHTLC _res_conv_15_conv;
21071                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
21072                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
21073                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
21074                 _res_constr.data[p] = _res_conv_15_conv;
21075         }
21076         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21077         CVec_UpdateAddHTLCZ_free(_res_constr);
21078 }
21079
21080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21081         LDKCVec_UpdateFulfillHTLCZ _res_constr;
21082         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21083         if (_res_constr.datalen > 0)
21084                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
21085         else
21086                 _res_constr.data = NULL;
21087         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21088         for (size_t t = 0; t < _res_constr.datalen; t++) {
21089                 int64_t _res_conv_19 = _res_vals[t];
21090                 LDKUpdateFulfillHTLC _res_conv_19_conv;
21091                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
21092                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
21093                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
21094                 _res_constr.data[t] = _res_conv_19_conv;
21095         }
21096         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21097         CVec_UpdateFulfillHTLCZ_free(_res_constr);
21098 }
21099
21100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21101         LDKCVec_UpdateFailHTLCZ _res_constr;
21102         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21103         if (_res_constr.datalen > 0)
21104                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
21105         else
21106                 _res_constr.data = NULL;
21107         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21108         for (size_t q = 0; q < _res_constr.datalen; q++) {
21109                 int64_t _res_conv_16 = _res_vals[q];
21110                 LDKUpdateFailHTLC _res_conv_16_conv;
21111                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
21112                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
21113                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21114                 _res_constr.data[q] = _res_conv_16_conv;
21115         }
21116         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21117         CVec_UpdateFailHTLCZ_free(_res_constr);
21118 }
21119
21120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21121         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
21122         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21123         if (_res_constr.datalen > 0)
21124                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
21125         else
21126                 _res_constr.data = NULL;
21127         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21128         for (size_t z = 0; z < _res_constr.datalen; z++) {
21129                 int64_t _res_conv_25 = _res_vals[z];
21130                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
21131                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
21132                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
21133                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
21134                 _res_constr.data[z] = _res_conv_25_conv;
21135         }
21136         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21137         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
21138 }
21139
21140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21141         LDKAcceptChannel o_conv;
21142         o_conv.inner = (void*)(o & (~1));
21143         o_conv.is_owned = (o & 1) || (o == 0);
21144         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21145         o_conv = AcceptChannel_clone(&o_conv);
21146         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21147         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
21148         return (int64_t)ret_conv;
21149 }
21150
21151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21152         LDKDecodeError e_conv;
21153         e_conv.inner = (void*)(e & (~1));
21154         e_conv.is_owned = (e & 1) || (e == 0);
21155         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21156         e_conv = DecodeError_clone(&e_conv);
21157         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21158         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
21159         return (int64_t)ret_conv;
21160 }
21161
21162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21163         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
21164         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
21165         return ret_conv;
21166 }
21167
21168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21169         if ((_res & 1) != 0) return;
21170         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21171         CHECK_ACCESS(_res_ptr);
21172         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
21173         FREE((void*)_res);
21174         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
21175 }
21176
21177 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
21178         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21179         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
21180         return (int64_t)ret_conv;
21181 }
21182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21183         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
21184         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
21185         return ret_conv;
21186 }
21187
21188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21189         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
21190         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
21191         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
21192         return (int64_t)ret_conv;
21193 }
21194
21195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21196         LDKAnnouncementSignatures o_conv;
21197         o_conv.inner = (void*)(o & (~1));
21198         o_conv.is_owned = (o & 1) || (o == 0);
21199         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21200         o_conv = AnnouncementSignatures_clone(&o_conv);
21201         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21202         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
21203         return (int64_t)ret_conv;
21204 }
21205
21206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21207         LDKDecodeError e_conv;
21208         e_conv.inner = (void*)(e & (~1));
21209         e_conv.is_owned = (e & 1) || (e == 0);
21210         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21211         e_conv = DecodeError_clone(&e_conv);
21212         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21213         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
21214         return (int64_t)ret_conv;
21215 }
21216
21217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21218         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
21219         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
21220         return ret_conv;
21221 }
21222
21223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21224         if ((_res & 1) != 0) return;
21225         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21226         CHECK_ACCESS(_res_ptr);
21227         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
21228         FREE((void*)_res);
21229         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
21230 }
21231
21232 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
21233         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21234         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
21235         return (int64_t)ret_conv;
21236 }
21237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21238         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
21239         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
21240         return ret_conv;
21241 }
21242
21243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21244         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
21245         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
21246         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
21247         return (int64_t)ret_conv;
21248 }
21249
21250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21251         LDKChannelReestablish o_conv;
21252         o_conv.inner = (void*)(o & (~1));
21253         o_conv.is_owned = (o & 1) || (o == 0);
21254         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21255         o_conv = ChannelReestablish_clone(&o_conv);
21256         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21257         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
21258         return (int64_t)ret_conv;
21259 }
21260
21261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21262         LDKDecodeError e_conv;
21263         e_conv.inner = (void*)(e & (~1));
21264         e_conv.is_owned = (e & 1) || (e == 0);
21265         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21266         e_conv = DecodeError_clone(&e_conv);
21267         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21268         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
21269         return (int64_t)ret_conv;
21270 }
21271
21272 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21273         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
21274         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
21275         return ret_conv;
21276 }
21277
21278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21279         if ((_res & 1) != 0) return;
21280         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21281         CHECK_ACCESS(_res_ptr);
21282         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
21283         FREE((void*)_res);
21284         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
21285 }
21286
21287 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
21288         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21289         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
21290         return (int64_t)ret_conv;
21291 }
21292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21293         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
21294         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
21295         return ret_conv;
21296 }
21297
21298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21299         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
21300         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
21301         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
21302         return (int64_t)ret_conv;
21303 }
21304
21305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21306         LDKClosingSigned o_conv;
21307         o_conv.inner = (void*)(o & (~1));
21308         o_conv.is_owned = (o & 1) || (o == 0);
21309         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21310         o_conv = ClosingSigned_clone(&o_conv);
21311         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21312         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
21313         return (int64_t)ret_conv;
21314 }
21315
21316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21317         LDKDecodeError e_conv;
21318         e_conv.inner = (void*)(e & (~1));
21319         e_conv.is_owned = (e & 1) || (e == 0);
21320         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21321         e_conv = DecodeError_clone(&e_conv);
21322         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21323         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
21324         return (int64_t)ret_conv;
21325 }
21326
21327 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21328         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
21329         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
21330         return ret_conv;
21331 }
21332
21333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21334         if ((_res & 1) != 0) return;
21335         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21336         CHECK_ACCESS(_res_ptr);
21337         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
21338         FREE((void*)_res);
21339         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
21340 }
21341
21342 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
21343         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21344         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
21345         return (int64_t)ret_conv;
21346 }
21347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21348         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
21349         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
21350         return ret_conv;
21351 }
21352
21353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21354         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
21355         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
21356         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
21357         return (int64_t)ret_conv;
21358 }
21359
21360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21361         LDKClosingSignedFeeRange o_conv;
21362         o_conv.inner = (void*)(o & (~1));
21363         o_conv.is_owned = (o & 1) || (o == 0);
21364         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21365         o_conv = ClosingSignedFeeRange_clone(&o_conv);
21366         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21367         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
21368         return (int64_t)ret_conv;
21369 }
21370
21371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21372         LDKDecodeError e_conv;
21373         e_conv.inner = (void*)(e & (~1));
21374         e_conv.is_owned = (e & 1) || (e == 0);
21375         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21376         e_conv = DecodeError_clone(&e_conv);
21377         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21378         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
21379         return (int64_t)ret_conv;
21380 }
21381
21382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21383         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
21384         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
21385         return ret_conv;
21386 }
21387
21388 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21389         if ((_res & 1) != 0) return;
21390         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21391         CHECK_ACCESS(_res_ptr);
21392         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
21393         FREE((void*)_res);
21394         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
21395 }
21396
21397 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
21398         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21399         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
21400         return (int64_t)ret_conv;
21401 }
21402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21403         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
21404         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
21405         return ret_conv;
21406 }
21407
21408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21409         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
21410         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
21411         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
21412         return (int64_t)ret_conv;
21413 }
21414
21415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21416         LDKCommitmentSigned o_conv;
21417         o_conv.inner = (void*)(o & (~1));
21418         o_conv.is_owned = (o & 1) || (o == 0);
21419         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21420         o_conv = CommitmentSigned_clone(&o_conv);
21421         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21422         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
21423         return (int64_t)ret_conv;
21424 }
21425
21426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21427         LDKDecodeError e_conv;
21428         e_conv.inner = (void*)(e & (~1));
21429         e_conv.is_owned = (e & 1) || (e == 0);
21430         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21431         e_conv = DecodeError_clone(&e_conv);
21432         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21433         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
21434         return (int64_t)ret_conv;
21435 }
21436
21437 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21438         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
21439         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
21440         return ret_conv;
21441 }
21442
21443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21444         if ((_res & 1) != 0) return;
21445         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21446         CHECK_ACCESS(_res_ptr);
21447         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
21448         FREE((void*)_res);
21449         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
21450 }
21451
21452 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
21453         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21454         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
21455         return (int64_t)ret_conv;
21456 }
21457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21458         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
21459         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
21460         return ret_conv;
21461 }
21462
21463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21464         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
21465         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
21466         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
21467         return (int64_t)ret_conv;
21468 }
21469
21470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21471         LDKFundingCreated o_conv;
21472         o_conv.inner = (void*)(o & (~1));
21473         o_conv.is_owned = (o & 1) || (o == 0);
21474         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21475         o_conv = FundingCreated_clone(&o_conv);
21476         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21477         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
21478         return (int64_t)ret_conv;
21479 }
21480
21481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21482         LDKDecodeError e_conv;
21483         e_conv.inner = (void*)(e & (~1));
21484         e_conv.is_owned = (e & 1) || (e == 0);
21485         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21486         e_conv = DecodeError_clone(&e_conv);
21487         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21488         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
21489         return (int64_t)ret_conv;
21490 }
21491
21492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21493         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
21494         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
21495         return ret_conv;
21496 }
21497
21498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21499         if ((_res & 1) != 0) return;
21500         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21501         CHECK_ACCESS(_res_ptr);
21502         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
21503         FREE((void*)_res);
21504         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
21505 }
21506
21507 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
21508         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21509         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
21510         return (int64_t)ret_conv;
21511 }
21512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21513         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
21514         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
21515         return ret_conv;
21516 }
21517
21518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21519         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
21520         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
21521         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
21522         return (int64_t)ret_conv;
21523 }
21524
21525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21526         LDKFundingSigned o_conv;
21527         o_conv.inner = (void*)(o & (~1));
21528         o_conv.is_owned = (o & 1) || (o == 0);
21529         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21530         o_conv = FundingSigned_clone(&o_conv);
21531         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21532         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
21533         return (int64_t)ret_conv;
21534 }
21535
21536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21537         LDKDecodeError e_conv;
21538         e_conv.inner = (void*)(e & (~1));
21539         e_conv.is_owned = (e & 1) || (e == 0);
21540         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21541         e_conv = DecodeError_clone(&e_conv);
21542         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21543         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
21544         return (int64_t)ret_conv;
21545 }
21546
21547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21548         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
21549         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
21550         return ret_conv;
21551 }
21552
21553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21554         if ((_res & 1) != 0) return;
21555         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21556         CHECK_ACCESS(_res_ptr);
21557         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
21558         FREE((void*)_res);
21559         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
21560 }
21561
21562 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
21563         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21564         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
21565         return (int64_t)ret_conv;
21566 }
21567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21568         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
21569         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
21570         return ret_conv;
21571 }
21572
21573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21574         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
21575         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
21576         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
21577         return (int64_t)ret_conv;
21578 }
21579
21580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21581         LDKFundingLocked o_conv;
21582         o_conv.inner = (void*)(o & (~1));
21583         o_conv.is_owned = (o & 1) || (o == 0);
21584         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21585         o_conv = FundingLocked_clone(&o_conv);
21586         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21587         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
21588         return (int64_t)ret_conv;
21589 }
21590
21591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21592         LDKDecodeError e_conv;
21593         e_conv.inner = (void*)(e & (~1));
21594         e_conv.is_owned = (e & 1) || (e == 0);
21595         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21596         e_conv = DecodeError_clone(&e_conv);
21597         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21598         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
21599         return (int64_t)ret_conv;
21600 }
21601
21602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21603         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
21604         jboolean ret_conv = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
21605         return ret_conv;
21606 }
21607
21608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21609         if ((_res & 1) != 0) return;
21610         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21611         CHECK_ACCESS(_res_ptr);
21612         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
21613         FREE((void*)_res);
21614         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
21615 }
21616
21617 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
21618         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21619         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
21620         return (int64_t)ret_conv;
21621 }
21622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21623         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
21624         int64_t ret_conv = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
21625         return ret_conv;
21626 }
21627
21628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21629         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
21630         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
21631         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
21632         return (int64_t)ret_conv;
21633 }
21634
21635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21636         LDKInit o_conv;
21637         o_conv.inner = (void*)(o & (~1));
21638         o_conv.is_owned = (o & 1) || (o == 0);
21639         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21640         o_conv = Init_clone(&o_conv);
21641         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21642         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
21643         return (int64_t)ret_conv;
21644 }
21645
21646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21647         LDKDecodeError e_conv;
21648         e_conv.inner = (void*)(e & (~1));
21649         e_conv.is_owned = (e & 1) || (e == 0);
21650         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21651         e_conv = DecodeError_clone(&e_conv);
21652         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21653         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
21654         return (int64_t)ret_conv;
21655 }
21656
21657 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21658         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
21659         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
21660         return ret_conv;
21661 }
21662
21663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21664         if ((_res & 1) != 0) return;
21665         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21666         CHECK_ACCESS(_res_ptr);
21667         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
21668         FREE((void*)_res);
21669         CResult_InitDecodeErrorZ_free(_res_conv);
21670 }
21671
21672 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
21673         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21674         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
21675         return (int64_t)ret_conv;
21676 }
21677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21678         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
21679         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
21680         return ret_conv;
21681 }
21682
21683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21684         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
21685         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
21686         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
21687         return (int64_t)ret_conv;
21688 }
21689
21690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21691         LDKOpenChannel o_conv;
21692         o_conv.inner = (void*)(o & (~1));
21693         o_conv.is_owned = (o & 1) || (o == 0);
21694         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21695         o_conv = OpenChannel_clone(&o_conv);
21696         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21697         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
21698         return (int64_t)ret_conv;
21699 }
21700
21701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21702         LDKDecodeError e_conv;
21703         e_conv.inner = (void*)(e & (~1));
21704         e_conv.is_owned = (e & 1) || (e == 0);
21705         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21706         e_conv = DecodeError_clone(&e_conv);
21707         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21708         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
21709         return (int64_t)ret_conv;
21710 }
21711
21712 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21713         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
21714         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
21715         return ret_conv;
21716 }
21717
21718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21719         if ((_res & 1) != 0) return;
21720         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21721         CHECK_ACCESS(_res_ptr);
21722         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
21723         FREE((void*)_res);
21724         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
21725 }
21726
21727 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
21728         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21729         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
21730         return (int64_t)ret_conv;
21731 }
21732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21733         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
21734         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
21735         return ret_conv;
21736 }
21737
21738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21739         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
21740         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
21741         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
21742         return (int64_t)ret_conv;
21743 }
21744
21745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21746         LDKRevokeAndACK o_conv;
21747         o_conv.inner = (void*)(o & (~1));
21748         o_conv.is_owned = (o & 1) || (o == 0);
21749         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21750         o_conv = RevokeAndACK_clone(&o_conv);
21751         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21752         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
21753         return (int64_t)ret_conv;
21754 }
21755
21756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21757         LDKDecodeError e_conv;
21758         e_conv.inner = (void*)(e & (~1));
21759         e_conv.is_owned = (e & 1) || (e == 0);
21760         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21761         e_conv = DecodeError_clone(&e_conv);
21762         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21763         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
21764         return (int64_t)ret_conv;
21765 }
21766
21767 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21768         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
21769         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
21770         return ret_conv;
21771 }
21772
21773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21774         if ((_res & 1) != 0) return;
21775         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21776         CHECK_ACCESS(_res_ptr);
21777         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
21778         FREE((void*)_res);
21779         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
21780 }
21781
21782 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
21783         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21784         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
21785         return (int64_t)ret_conv;
21786 }
21787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21788         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
21789         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
21790         return ret_conv;
21791 }
21792
21793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21794         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
21795         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
21796         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
21797         return (int64_t)ret_conv;
21798 }
21799
21800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21801         LDKShutdown o_conv;
21802         o_conv.inner = (void*)(o & (~1));
21803         o_conv.is_owned = (o & 1) || (o == 0);
21804         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21805         o_conv = Shutdown_clone(&o_conv);
21806         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21807         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
21808         return (int64_t)ret_conv;
21809 }
21810
21811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21812         LDKDecodeError e_conv;
21813         e_conv.inner = (void*)(e & (~1));
21814         e_conv.is_owned = (e & 1) || (e == 0);
21815         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21816         e_conv = DecodeError_clone(&e_conv);
21817         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21818         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
21819         return (int64_t)ret_conv;
21820 }
21821
21822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21823         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
21824         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
21825         return ret_conv;
21826 }
21827
21828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21829         if ((_res & 1) != 0) return;
21830         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21831         CHECK_ACCESS(_res_ptr);
21832         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
21833         FREE((void*)_res);
21834         CResult_ShutdownDecodeErrorZ_free(_res_conv);
21835 }
21836
21837 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
21838         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21839         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
21840         return (int64_t)ret_conv;
21841 }
21842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21843         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
21844         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
21845         return ret_conv;
21846 }
21847
21848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21849         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
21850         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
21851         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
21852         return (int64_t)ret_conv;
21853 }
21854
21855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21856         LDKUpdateFailHTLC o_conv;
21857         o_conv.inner = (void*)(o & (~1));
21858         o_conv.is_owned = (o & 1) || (o == 0);
21859         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21860         o_conv = UpdateFailHTLC_clone(&o_conv);
21861         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21862         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
21863         return (int64_t)ret_conv;
21864 }
21865
21866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21867         LDKDecodeError e_conv;
21868         e_conv.inner = (void*)(e & (~1));
21869         e_conv.is_owned = (e & 1) || (e == 0);
21870         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21871         e_conv = DecodeError_clone(&e_conv);
21872         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21873         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
21874         return (int64_t)ret_conv;
21875 }
21876
21877 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21878         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
21879         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
21880         return ret_conv;
21881 }
21882
21883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21884         if ((_res & 1) != 0) return;
21885         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21886         CHECK_ACCESS(_res_ptr);
21887         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
21888         FREE((void*)_res);
21889         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
21890 }
21891
21892 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
21893         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21894         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
21895         return (int64_t)ret_conv;
21896 }
21897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21898         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
21899         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
21900         return ret_conv;
21901 }
21902
21903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21904         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
21905         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
21906         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
21907         return (int64_t)ret_conv;
21908 }
21909
21910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21911         LDKUpdateFailMalformedHTLC o_conv;
21912         o_conv.inner = (void*)(o & (~1));
21913         o_conv.is_owned = (o & 1) || (o == 0);
21914         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21915         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
21916         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21917         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
21918         return (int64_t)ret_conv;
21919 }
21920
21921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21922         LDKDecodeError e_conv;
21923         e_conv.inner = (void*)(e & (~1));
21924         e_conv.is_owned = (e & 1) || (e == 0);
21925         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21926         e_conv = DecodeError_clone(&e_conv);
21927         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21928         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
21929         return (int64_t)ret_conv;
21930 }
21931
21932 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21933         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
21934         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
21935         return ret_conv;
21936 }
21937
21938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21939         if ((_res & 1) != 0) return;
21940         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21941         CHECK_ACCESS(_res_ptr);
21942         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
21943         FREE((void*)_res);
21944         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
21945 }
21946
21947 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
21948         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21949         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
21950         return (int64_t)ret_conv;
21951 }
21952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21953         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
21954         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
21955         return ret_conv;
21956 }
21957
21958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21959         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
21960         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
21961         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
21962         return (int64_t)ret_conv;
21963 }
21964
21965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21966         LDKUpdateFee o_conv;
21967         o_conv.inner = (void*)(o & (~1));
21968         o_conv.is_owned = (o & 1) || (o == 0);
21969         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21970         o_conv = UpdateFee_clone(&o_conv);
21971         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21972         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
21973         return (int64_t)ret_conv;
21974 }
21975
21976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21977         LDKDecodeError e_conv;
21978         e_conv.inner = (void*)(e & (~1));
21979         e_conv.is_owned = (e & 1) || (e == 0);
21980         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21981         e_conv = DecodeError_clone(&e_conv);
21982         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
21983         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
21984         return (int64_t)ret_conv;
21985 }
21986
21987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21988         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
21989         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
21990         return ret_conv;
21991 }
21992
21993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21994         if ((_res & 1) != 0) return;
21995         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
21996         CHECK_ACCESS(_res_ptr);
21997         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
21998         FREE((void*)_res);
21999         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
22000 }
22001
22002 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
22003         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22004         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
22005         return (int64_t)ret_conv;
22006 }
22007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22008         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
22009         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
22010         return ret_conv;
22011 }
22012
22013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22014         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
22015         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
22016         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
22017         return (int64_t)ret_conv;
22018 }
22019
22020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22021         LDKUpdateFulfillHTLC o_conv;
22022         o_conv.inner = (void*)(o & (~1));
22023         o_conv.is_owned = (o & 1) || (o == 0);
22024         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22025         o_conv = UpdateFulfillHTLC_clone(&o_conv);
22026         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22027         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
22028         return (int64_t)ret_conv;
22029 }
22030
22031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22032         LDKDecodeError e_conv;
22033         e_conv.inner = (void*)(e & (~1));
22034         e_conv.is_owned = (e & 1) || (e == 0);
22035         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22036         e_conv = DecodeError_clone(&e_conv);
22037         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22038         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
22039         return (int64_t)ret_conv;
22040 }
22041
22042 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22043         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
22044         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
22045         return ret_conv;
22046 }
22047
22048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22049         if ((_res & 1) != 0) return;
22050         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22051         CHECK_ACCESS(_res_ptr);
22052         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
22053         FREE((void*)_res);
22054         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
22055 }
22056
22057 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
22058         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22059         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
22060         return (int64_t)ret_conv;
22061 }
22062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22063         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
22064         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
22065         return ret_conv;
22066 }
22067
22068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22069         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
22070         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
22071         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
22072         return (int64_t)ret_conv;
22073 }
22074
22075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22076         LDKUpdateAddHTLC o_conv;
22077         o_conv.inner = (void*)(o & (~1));
22078         o_conv.is_owned = (o & 1) || (o == 0);
22079         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22080         o_conv = UpdateAddHTLC_clone(&o_conv);
22081         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22082         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
22083         return (int64_t)ret_conv;
22084 }
22085
22086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22087         LDKDecodeError e_conv;
22088         e_conv.inner = (void*)(e & (~1));
22089         e_conv.is_owned = (e & 1) || (e == 0);
22090         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22091         e_conv = DecodeError_clone(&e_conv);
22092         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22093         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
22094         return (int64_t)ret_conv;
22095 }
22096
22097 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22098         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
22099         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
22100         return ret_conv;
22101 }
22102
22103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22104         if ((_res & 1) != 0) return;
22105         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22106         CHECK_ACCESS(_res_ptr);
22107         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
22108         FREE((void*)_res);
22109         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
22110 }
22111
22112 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
22113         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22114         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
22115         return (int64_t)ret_conv;
22116 }
22117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22118         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
22119         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
22120         return ret_conv;
22121 }
22122
22123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22124         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
22125         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
22126         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
22127         return (int64_t)ret_conv;
22128 }
22129
22130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22131         LDKPing o_conv;
22132         o_conv.inner = (void*)(o & (~1));
22133         o_conv.is_owned = (o & 1) || (o == 0);
22134         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22135         o_conv = Ping_clone(&o_conv);
22136         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22137         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
22138         return (int64_t)ret_conv;
22139 }
22140
22141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22142         LDKDecodeError e_conv;
22143         e_conv.inner = (void*)(e & (~1));
22144         e_conv.is_owned = (e & 1) || (e == 0);
22145         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22146         e_conv = DecodeError_clone(&e_conv);
22147         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22148         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
22149         return (int64_t)ret_conv;
22150 }
22151
22152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22153         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
22154         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
22155         return ret_conv;
22156 }
22157
22158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22159         if ((_res & 1) != 0) return;
22160         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22161         CHECK_ACCESS(_res_ptr);
22162         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
22163         FREE((void*)_res);
22164         CResult_PingDecodeErrorZ_free(_res_conv);
22165 }
22166
22167 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
22168         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22169         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
22170         return (int64_t)ret_conv;
22171 }
22172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22173         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
22174         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
22175         return ret_conv;
22176 }
22177
22178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22179         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
22180         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
22181         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
22182         return (int64_t)ret_conv;
22183 }
22184
22185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22186         LDKPong o_conv;
22187         o_conv.inner = (void*)(o & (~1));
22188         o_conv.is_owned = (o & 1) || (o == 0);
22189         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22190         o_conv = Pong_clone(&o_conv);
22191         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22192         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
22193         return (int64_t)ret_conv;
22194 }
22195
22196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22197         LDKDecodeError e_conv;
22198         e_conv.inner = (void*)(e & (~1));
22199         e_conv.is_owned = (e & 1) || (e == 0);
22200         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22201         e_conv = DecodeError_clone(&e_conv);
22202         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22203         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
22204         return (int64_t)ret_conv;
22205 }
22206
22207 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22208         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
22209         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
22210         return ret_conv;
22211 }
22212
22213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22214         if ((_res & 1) != 0) return;
22215         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22216         CHECK_ACCESS(_res_ptr);
22217         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
22218         FREE((void*)_res);
22219         CResult_PongDecodeErrorZ_free(_res_conv);
22220 }
22221
22222 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
22223         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22224         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
22225         return (int64_t)ret_conv;
22226 }
22227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22228         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
22229         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
22230         return ret_conv;
22231 }
22232
22233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22234         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
22235         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
22236         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
22237         return (int64_t)ret_conv;
22238 }
22239
22240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22241         LDKUnsignedChannelAnnouncement o_conv;
22242         o_conv.inner = (void*)(o & (~1));
22243         o_conv.is_owned = (o & 1) || (o == 0);
22244         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22245         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
22246         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22247         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
22248         return (int64_t)ret_conv;
22249 }
22250
22251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22252         LDKDecodeError e_conv;
22253         e_conv.inner = (void*)(e & (~1));
22254         e_conv.is_owned = (e & 1) || (e == 0);
22255         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22256         e_conv = DecodeError_clone(&e_conv);
22257         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22258         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
22259         return (int64_t)ret_conv;
22260 }
22261
22262 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22263         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
22264         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
22265         return ret_conv;
22266 }
22267
22268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22269         if ((_res & 1) != 0) return;
22270         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22271         CHECK_ACCESS(_res_ptr);
22272         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
22273         FREE((void*)_res);
22274         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
22275 }
22276
22277 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22278         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22279         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
22280         return (int64_t)ret_conv;
22281 }
22282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22283         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
22284         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22285         return ret_conv;
22286 }
22287
22288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22289         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
22290         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
22291         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
22292         return (int64_t)ret_conv;
22293 }
22294
22295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22296         LDKChannelAnnouncement o_conv;
22297         o_conv.inner = (void*)(o & (~1));
22298         o_conv.is_owned = (o & 1) || (o == 0);
22299         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22300         o_conv = ChannelAnnouncement_clone(&o_conv);
22301         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22302         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
22303         return (int64_t)ret_conv;
22304 }
22305
22306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22307         LDKDecodeError e_conv;
22308         e_conv.inner = (void*)(e & (~1));
22309         e_conv.is_owned = (e & 1) || (e == 0);
22310         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22311         e_conv = DecodeError_clone(&e_conv);
22312         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22313         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
22314         return (int64_t)ret_conv;
22315 }
22316
22317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22318         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
22319         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
22320         return ret_conv;
22321 }
22322
22323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22324         if ((_res & 1) != 0) return;
22325         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22326         CHECK_ACCESS(_res_ptr);
22327         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
22328         FREE((void*)_res);
22329         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
22330 }
22331
22332 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22333         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22334         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
22335         return (int64_t)ret_conv;
22336 }
22337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22338         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
22339         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22340         return ret_conv;
22341 }
22342
22343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22344         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
22345         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
22346         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
22347         return (int64_t)ret_conv;
22348 }
22349
22350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22351         LDKUnsignedChannelUpdate o_conv;
22352         o_conv.inner = (void*)(o & (~1));
22353         o_conv.is_owned = (o & 1) || (o == 0);
22354         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22355         o_conv = UnsignedChannelUpdate_clone(&o_conv);
22356         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22357         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
22358         return (int64_t)ret_conv;
22359 }
22360
22361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22362         LDKDecodeError e_conv;
22363         e_conv.inner = (void*)(e & (~1));
22364         e_conv.is_owned = (e & 1) || (e == 0);
22365         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22366         e_conv = DecodeError_clone(&e_conv);
22367         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22368         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
22369         return (int64_t)ret_conv;
22370 }
22371
22372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22373         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
22374         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
22375         return ret_conv;
22376 }
22377
22378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22379         if ((_res & 1) != 0) return;
22380         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22381         CHECK_ACCESS(_res_ptr);
22382         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
22383         FREE((void*)_res);
22384         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
22385 }
22386
22387 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
22388         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22389         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
22390         return (int64_t)ret_conv;
22391 }
22392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22393         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
22394         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
22395         return ret_conv;
22396 }
22397
22398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22399         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
22400         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
22401         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
22402         return (int64_t)ret_conv;
22403 }
22404
22405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22406         LDKChannelUpdate o_conv;
22407         o_conv.inner = (void*)(o & (~1));
22408         o_conv.is_owned = (o & 1) || (o == 0);
22409         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22410         o_conv = ChannelUpdate_clone(&o_conv);
22411         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22412         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
22413         return (int64_t)ret_conv;
22414 }
22415
22416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22417         LDKDecodeError e_conv;
22418         e_conv.inner = (void*)(e & (~1));
22419         e_conv.is_owned = (e & 1) || (e == 0);
22420         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22421         e_conv = DecodeError_clone(&e_conv);
22422         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22423         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
22424         return (int64_t)ret_conv;
22425 }
22426
22427 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22428         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
22429         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
22430         return ret_conv;
22431 }
22432
22433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22434         if ((_res & 1) != 0) return;
22435         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22436         CHECK_ACCESS(_res_ptr);
22437         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
22438         FREE((void*)_res);
22439         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
22440 }
22441
22442 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
22443         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22444         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
22445         return (int64_t)ret_conv;
22446 }
22447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22448         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
22449         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
22450         return ret_conv;
22451 }
22452
22453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22454         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
22455         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
22456         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
22457         return (int64_t)ret_conv;
22458 }
22459
22460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22461         LDKErrorMessage o_conv;
22462         o_conv.inner = (void*)(o & (~1));
22463         o_conv.is_owned = (o & 1) || (o == 0);
22464         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22465         o_conv = ErrorMessage_clone(&o_conv);
22466         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22467         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
22468         return (int64_t)ret_conv;
22469 }
22470
22471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22472         LDKDecodeError e_conv;
22473         e_conv.inner = (void*)(e & (~1));
22474         e_conv.is_owned = (e & 1) || (e == 0);
22475         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22476         e_conv = DecodeError_clone(&e_conv);
22477         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22478         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
22479         return (int64_t)ret_conv;
22480 }
22481
22482 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22483         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
22484         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
22485         return ret_conv;
22486 }
22487
22488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22489         if ((_res & 1) != 0) return;
22490         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22491         CHECK_ACCESS(_res_ptr);
22492         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
22493         FREE((void*)_res);
22494         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
22495 }
22496
22497 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
22498         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22499         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
22500         return (int64_t)ret_conv;
22501 }
22502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22503         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
22504         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
22505         return ret_conv;
22506 }
22507
22508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22509         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
22510         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
22511         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
22512         return (int64_t)ret_conv;
22513 }
22514
22515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22516         LDKWarningMessage o_conv;
22517         o_conv.inner = (void*)(o & (~1));
22518         o_conv.is_owned = (o & 1) || (o == 0);
22519         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22520         o_conv = WarningMessage_clone(&o_conv);
22521         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22522         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
22523         return (int64_t)ret_conv;
22524 }
22525
22526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22527         LDKDecodeError e_conv;
22528         e_conv.inner = (void*)(e & (~1));
22529         e_conv.is_owned = (e & 1) || (e == 0);
22530         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22531         e_conv = DecodeError_clone(&e_conv);
22532         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22533         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
22534         return (int64_t)ret_conv;
22535 }
22536
22537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22538         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
22539         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
22540         return ret_conv;
22541 }
22542
22543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22544         if ((_res & 1) != 0) return;
22545         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22546         CHECK_ACCESS(_res_ptr);
22547         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
22548         FREE((void*)_res);
22549         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
22550 }
22551
22552 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
22553         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22554         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
22555         return (int64_t)ret_conv;
22556 }
22557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22558         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
22559         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
22560         return ret_conv;
22561 }
22562
22563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22564         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
22565         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
22566         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
22567         return (int64_t)ret_conv;
22568 }
22569
22570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22571         LDKUnsignedNodeAnnouncement o_conv;
22572         o_conv.inner = (void*)(o & (~1));
22573         o_conv.is_owned = (o & 1) || (o == 0);
22574         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22575         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
22576         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22577         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
22578         return (int64_t)ret_conv;
22579 }
22580
22581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22582         LDKDecodeError e_conv;
22583         e_conv.inner = (void*)(e & (~1));
22584         e_conv.is_owned = (e & 1) || (e == 0);
22585         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22586         e_conv = DecodeError_clone(&e_conv);
22587         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22588         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
22589         return (int64_t)ret_conv;
22590 }
22591
22592 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22593         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
22594         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22595         return ret_conv;
22596 }
22597
22598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22599         if ((_res & 1) != 0) return;
22600         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22601         CHECK_ACCESS(_res_ptr);
22602         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
22603         FREE((void*)_res);
22604         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
22605 }
22606
22607 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22608         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22609         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
22610         return (int64_t)ret_conv;
22611 }
22612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22613         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
22614         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22615         return ret_conv;
22616 }
22617
22618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22619         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
22620         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
22621         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
22622         return (int64_t)ret_conv;
22623 }
22624
22625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22626         LDKNodeAnnouncement o_conv;
22627         o_conv.inner = (void*)(o & (~1));
22628         o_conv.is_owned = (o & 1) || (o == 0);
22629         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22630         o_conv = NodeAnnouncement_clone(&o_conv);
22631         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22632         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
22633         return (int64_t)ret_conv;
22634 }
22635
22636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22637         LDKDecodeError e_conv;
22638         e_conv.inner = (void*)(e & (~1));
22639         e_conv.is_owned = (e & 1) || (e == 0);
22640         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22641         e_conv = DecodeError_clone(&e_conv);
22642         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22643         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
22644         return (int64_t)ret_conv;
22645 }
22646
22647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22648         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
22649         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
22650         return ret_conv;
22651 }
22652
22653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22654         if ((_res & 1) != 0) return;
22655         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22656         CHECK_ACCESS(_res_ptr);
22657         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
22658         FREE((void*)_res);
22659         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
22660 }
22661
22662 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
22663         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22664         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
22665         return (int64_t)ret_conv;
22666 }
22667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22668         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
22669         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
22670         return ret_conv;
22671 }
22672
22673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22674         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
22675         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
22676         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
22677         return (int64_t)ret_conv;
22678 }
22679
22680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22681         LDKQueryShortChannelIds o_conv;
22682         o_conv.inner = (void*)(o & (~1));
22683         o_conv.is_owned = (o & 1) || (o == 0);
22684         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22685         o_conv = QueryShortChannelIds_clone(&o_conv);
22686         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22687         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
22688         return (int64_t)ret_conv;
22689 }
22690
22691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22692         LDKDecodeError e_conv;
22693         e_conv.inner = (void*)(e & (~1));
22694         e_conv.is_owned = (e & 1) || (e == 0);
22695         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22696         e_conv = DecodeError_clone(&e_conv);
22697         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22698         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
22699         return (int64_t)ret_conv;
22700 }
22701
22702 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22703         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
22704         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
22705         return ret_conv;
22706 }
22707
22708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22709         if ((_res & 1) != 0) return;
22710         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22711         CHECK_ACCESS(_res_ptr);
22712         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
22713         FREE((void*)_res);
22714         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
22715 }
22716
22717 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
22718         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22719         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
22720         return (int64_t)ret_conv;
22721 }
22722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22723         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
22724         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
22725         return ret_conv;
22726 }
22727
22728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22729         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
22730         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
22731         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
22732         return (int64_t)ret_conv;
22733 }
22734
22735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22736         LDKReplyShortChannelIdsEnd o_conv;
22737         o_conv.inner = (void*)(o & (~1));
22738         o_conv.is_owned = (o & 1) || (o == 0);
22739         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22740         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
22741         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22742         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
22743         return (int64_t)ret_conv;
22744 }
22745
22746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22747         LDKDecodeError e_conv;
22748         e_conv.inner = (void*)(e & (~1));
22749         e_conv.is_owned = (e & 1) || (e == 0);
22750         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22751         e_conv = DecodeError_clone(&e_conv);
22752         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22753         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
22754         return (int64_t)ret_conv;
22755 }
22756
22757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22758         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
22759         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
22760         return ret_conv;
22761 }
22762
22763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22764         if ((_res & 1) != 0) return;
22765         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22766         CHECK_ACCESS(_res_ptr);
22767         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
22768         FREE((void*)_res);
22769         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
22770 }
22771
22772 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
22773         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22774         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
22775         return (int64_t)ret_conv;
22776 }
22777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22778         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
22779         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
22780         return ret_conv;
22781 }
22782
22783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22784         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
22785         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
22786         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
22787         return (int64_t)ret_conv;
22788 }
22789
22790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22791         LDKQueryChannelRange o_conv;
22792         o_conv.inner = (void*)(o & (~1));
22793         o_conv.is_owned = (o & 1) || (o == 0);
22794         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22795         o_conv = QueryChannelRange_clone(&o_conv);
22796         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22797         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
22798         return (int64_t)ret_conv;
22799 }
22800
22801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22802         LDKDecodeError e_conv;
22803         e_conv.inner = (void*)(e & (~1));
22804         e_conv.is_owned = (e & 1) || (e == 0);
22805         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22806         e_conv = DecodeError_clone(&e_conv);
22807         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22808         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
22809         return (int64_t)ret_conv;
22810 }
22811
22812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22813         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
22814         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
22815         return ret_conv;
22816 }
22817
22818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22819         if ((_res & 1) != 0) return;
22820         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22821         CHECK_ACCESS(_res_ptr);
22822         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
22823         FREE((void*)_res);
22824         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
22825 }
22826
22827 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22828         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22829         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
22830         return (int64_t)ret_conv;
22831 }
22832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22833         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
22834         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22835         return ret_conv;
22836 }
22837
22838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22839         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
22840         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
22841         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
22842         return (int64_t)ret_conv;
22843 }
22844
22845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22846         LDKReplyChannelRange o_conv;
22847         o_conv.inner = (void*)(o & (~1));
22848         o_conv.is_owned = (o & 1) || (o == 0);
22849         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22850         o_conv = ReplyChannelRange_clone(&o_conv);
22851         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22852         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
22853         return (int64_t)ret_conv;
22854 }
22855
22856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22857         LDKDecodeError e_conv;
22858         e_conv.inner = (void*)(e & (~1));
22859         e_conv.is_owned = (e & 1) || (e == 0);
22860         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22861         e_conv = DecodeError_clone(&e_conv);
22862         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22863         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
22864         return (int64_t)ret_conv;
22865 }
22866
22867 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22868         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
22869         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
22870         return ret_conv;
22871 }
22872
22873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22874         if ((_res & 1) != 0) return;
22875         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22876         CHECK_ACCESS(_res_ptr);
22877         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
22878         FREE((void*)_res);
22879         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
22880 }
22881
22882 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
22883         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22884         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
22885         return (int64_t)ret_conv;
22886 }
22887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22888         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
22889         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
22890         return ret_conv;
22891 }
22892
22893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22894         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
22895         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
22896         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
22897         return (int64_t)ret_conv;
22898 }
22899
22900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22901         LDKGossipTimestampFilter o_conv;
22902         o_conv.inner = (void*)(o & (~1));
22903         o_conv.is_owned = (o & 1) || (o == 0);
22904         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22905         o_conv = GossipTimestampFilter_clone(&o_conv);
22906         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22907         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
22908         return (int64_t)ret_conv;
22909 }
22910
22911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22912         LDKDecodeError e_conv;
22913         e_conv.inner = (void*)(e & (~1));
22914         e_conv.is_owned = (e & 1) || (e == 0);
22915         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22916         e_conv = DecodeError_clone(&e_conv);
22917         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22918         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
22919         return (int64_t)ret_conv;
22920 }
22921
22922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22923         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
22924         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
22925         return ret_conv;
22926 }
22927
22928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22929         if ((_res & 1) != 0) return;
22930         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
22931         CHECK_ACCESS(_res_ptr);
22932         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
22933         FREE((void*)_res);
22934         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
22935 }
22936
22937 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
22938         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22939         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
22940         return (int64_t)ret_conv;
22941 }
22942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22943         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
22944         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
22945         return ret_conv;
22946 }
22947
22948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22949         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
22950         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
22951         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
22952         return (int64_t)ret_conv;
22953 }
22954
22955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22956         LDKCVec_PhantomRouteHintsZ _res_constr;
22957         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22958         if (_res_constr.datalen > 0)
22959                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
22960         else
22961                 _res_constr.data = NULL;
22962         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22963         for (size_t t = 0; t < _res_constr.datalen; t++) {
22964                 int64_t _res_conv_19 = _res_vals[t];
22965                 LDKPhantomRouteHints _res_conv_19_conv;
22966                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
22967                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
22968                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
22969                 _res_constr.data[t] = _res_conv_19_conv;
22970         }
22971         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22972         CVec_PhantomRouteHintsZ_free(_res_constr);
22973 }
22974
22975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22976         LDKInvoice o_conv;
22977         o_conv.inner = (void*)(o & (~1));
22978         o_conv.is_owned = (o & 1) || (o == 0);
22979         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22980         o_conv = Invoice_clone(&o_conv);
22981         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22982         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
22983         return (int64_t)ret_conv;
22984 }
22985
22986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22987         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
22988         CHECK_ACCESS(e_ptr);
22989         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
22990         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
22991         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
22992         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
22993         return (int64_t)ret_conv;
22994 }
22995
22996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22997         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
22998         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
22999         return ret_conv;
23000 }
23001
23002 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23003         if ((_res & 1) != 0) return;
23004         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23005         CHECK_ACCESS(_res_ptr);
23006         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
23007         FREE((void*)_res);
23008         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
23009 }
23010
23011 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
23012         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23013         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
23014         return (int64_t)ret_conv;
23015 }
23016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23017         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
23018         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
23019         return ret_conv;
23020 }
23021
23022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23023         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
23024         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
23025         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
23026         return (int64_t)ret_conv;
23027 }
23028
23029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
23030         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
23031         CHECK_ACCESS(o_ptr);
23032         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
23033         if (o_conv.free == LDKFilter_JCalls_free) {
23034                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23035                 LDKFilter_JCalls_cloned(&o_conv);
23036         }
23037         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
23038         *ret_copy = COption_FilterZ_some(o_conv);
23039         int64_t ret_ref = (uintptr_t)ret_copy;
23040         return ret_ref;
23041 }
23042
23043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
23044         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
23045         *ret_copy = COption_FilterZ_none();
23046         int64_t ret_ref = (uintptr_t)ret_copy;
23047         return ret_ref;
23048 }
23049
23050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23051         if ((_res & 1) != 0) return;
23052         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23053         CHECK_ACCESS(_res_ptr);
23054         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
23055         FREE((void*)_res);
23056         COption_FilterZ_free(_res_conv);
23057 }
23058
23059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23060         LDKLockedChannelMonitor o_conv;
23061         o_conv.inner = (void*)(o & (~1));
23062         o_conv.is_owned = (o & 1) || (o == 0);
23063         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23064         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
23065         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23066         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
23067         return (int64_t)ret_conv;
23068 }
23069
23070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
23071         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
23072         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
23073         return (int64_t)ret_conv;
23074 }
23075
23076 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23077         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
23078         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
23079         return ret_conv;
23080 }
23081
23082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23083         if ((_res & 1) != 0) return;
23084         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
23085         CHECK_ACCESS(_res_ptr);
23086         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
23087         FREE((void*)_res);
23088         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
23089 }
23090
23091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23092         LDKCVec_OutPointZ _res_constr;
23093         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23094         if (_res_constr.datalen > 0)
23095                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
23096         else
23097                 _res_constr.data = NULL;
23098         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23099         for (size_t k = 0; k < _res_constr.datalen; k++) {
23100                 int64_t _res_conv_10 = _res_vals[k];
23101                 LDKOutPoint _res_conv_10_conv;
23102                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
23103                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
23104                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
23105                 _res_constr.data[k] = _res_conv_10_conv;
23106         }
23107         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23108         CVec_OutPointZ_free(_res_constr);
23109 }
23110
23111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23112         if ((this_ptr & 1) != 0) return;
23113         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23114         CHECK_ACCESS(this_ptr_ptr);
23115         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
23116         FREE((void*)this_ptr);
23117         PaymentPurpose_free(this_ptr_conv);
23118 }
23119
23120 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
23121         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23122         *ret_copy = PaymentPurpose_clone(arg);
23123 int64_t ret_ref = (uintptr_t)ret_copy;
23124         return ret_ref;
23125 }
23126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23127         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
23128         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
23129         return ret_conv;
23130 }
23131
23132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23133         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
23134         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23135         *ret_copy = PaymentPurpose_clone(orig_conv);
23136         int64_t ret_ref = (uintptr_t)ret_copy;
23137         return ret_ref;
23138 }
23139
23140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
23141         LDKThirtyTwoBytes payment_preimage_ref;
23142         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23143         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23144         LDKThirtyTwoBytes payment_secret_ref;
23145         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
23146         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
23147         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23148         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
23149         int64_t ret_ref = (uintptr_t)ret_copy;
23150         return ret_ref;
23151 }
23152
23153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
23154         LDKThirtyTwoBytes a_ref;
23155         CHECK((*env)->GetArrayLength(env, a) == 32);
23156         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
23157         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
23158         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
23159         int64_t ret_ref = (uintptr_t)ret_copy;
23160         return ret_ref;
23161 }
23162
23163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23164         if ((this_ptr & 1) != 0) return;
23165         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23166         CHECK_ACCESS(this_ptr_ptr);
23167         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
23168         FREE((void*)this_ptr);
23169         ClosureReason_free(this_ptr_conv);
23170 }
23171
23172 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
23173         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23174         *ret_copy = ClosureReason_clone(arg);
23175 int64_t ret_ref = (uintptr_t)ret_copy;
23176         return ret_ref;
23177 }
23178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23179         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
23180         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
23181         return ret_conv;
23182 }
23183
23184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23185         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
23186         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23187         *ret_copy = ClosureReason_clone(orig_conv);
23188         int64_t ret_ref = (uintptr_t)ret_copy;
23189         return ret_ref;
23190 }
23191
23192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
23193         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
23194         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23195         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
23196         int64_t ret_ref = (uintptr_t)ret_copy;
23197         return ret_ref;
23198 }
23199
23200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
23201         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23202         *ret_copy = ClosureReason_holder_force_closed();
23203         int64_t ret_ref = (uintptr_t)ret_copy;
23204         return ret_ref;
23205 }
23206
23207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
23208         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23209         *ret_copy = ClosureReason_cooperative_closure();
23210         int64_t ret_ref = (uintptr_t)ret_copy;
23211         return ret_ref;
23212 }
23213
23214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
23215         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23216         *ret_copy = ClosureReason_commitment_tx_confirmed();
23217         int64_t ret_ref = (uintptr_t)ret_copy;
23218         return ret_ref;
23219 }
23220
23221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
23222         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23223         *ret_copy = ClosureReason_funding_timed_out();
23224         int64_t ret_ref = (uintptr_t)ret_copy;
23225         return ret_ref;
23226 }
23227
23228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
23229         LDKStr err_conv = java_to_owned_str(env, err);
23230         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23231         *ret_copy = ClosureReason_processing_error(err_conv);
23232         int64_t ret_ref = (uintptr_t)ret_copy;
23233         return ret_ref;
23234 }
23235
23236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
23237         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23238         *ret_copy = ClosureReason_disconnected_peer();
23239         int64_t ret_ref = (uintptr_t)ret_copy;
23240         return ret_ref;
23241 }
23242
23243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
23244         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
23245         *ret_copy = ClosureReason_outdated_channel_manager();
23246         int64_t ret_ref = (uintptr_t)ret_copy;
23247         return ret_ref;
23248 }
23249
23250 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
23251         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
23252         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
23253         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23254         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23255         CVec_u8Z_free(ret_var);
23256         return ret_arr;
23257 }
23258
23259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23260         LDKu8slice ser_ref;
23261         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23262         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23263         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
23264         *ret_conv = ClosureReason_read(ser_ref);
23265         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23266         return (int64_t)ret_conv;
23267 }
23268
23269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23270         if ((this_ptr & 1) != 0) return;
23271         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23272         CHECK_ACCESS(this_ptr_ptr);
23273         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
23274         FREE((void*)this_ptr);
23275         Event_free(this_ptr_conv);
23276 }
23277
23278 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
23279         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23280         *ret_copy = Event_clone(arg);
23281 int64_t ret_ref = (uintptr_t)ret_copy;
23282         return ret_ref;
23283 }
23284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23285         LDKEvent* arg_conv = (LDKEvent*)arg;
23286         int64_t ret_conv = Event_clone_ptr(arg_conv);
23287         return ret_conv;
23288 }
23289
23290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23291         LDKEvent* orig_conv = (LDKEvent*)orig;
23292         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23293         *ret_copy = Event_clone(orig_conv);
23294         int64_t ret_ref = (uintptr_t)ret_copy;
23295         return ret_ref;
23296 }
23297
23298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
23299         LDKThirtyTwoBytes temporary_channel_id_ref;
23300         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
23301         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
23302         LDKCVec_u8Z output_script_ref;
23303         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
23304         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
23305         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
23306         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23307         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
23308         int64_t ret_ref = (uintptr_t)ret_copy;
23309         return ret_ref;
23310 }
23311
23312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amt, int64_t purpose) {
23313         LDKThirtyTwoBytes payment_hash_ref;
23314         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23315         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23316         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
23317         CHECK_ACCESS(purpose_ptr);
23318         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
23319         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
23320         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23321         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
23322         int64_t ret_ref = (uintptr_t)ret_copy;
23323         return ret_ref;
23324 }
23325
23326 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) {
23327         LDKThirtyTwoBytes payment_id_ref;
23328         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23329         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23330         LDKThirtyTwoBytes payment_preimage_ref;
23331         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
23332         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
23333         LDKThirtyTwoBytes payment_hash_ref;
23334         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23335         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23336         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
23337         CHECK_ACCESS(fee_paid_msat_ptr);
23338         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
23339         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
23340         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23341         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
23342         int64_t ret_ref = (uintptr_t)ret_copy;
23343         return ret_ref;
23344 }
23345
23346 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) {
23347         LDKThirtyTwoBytes payment_id_ref;
23348         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23349         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23350         LDKThirtyTwoBytes payment_hash_ref;
23351         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23352         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23353         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
23354         CHECK_ACCESS(network_update_ptr);
23355         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
23356         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
23357         LDKCVec_RouteHopZ path_constr;
23358         path_constr.datalen = (*env)->GetArrayLength(env, path);
23359         if (path_constr.datalen > 0)
23360                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23361         else
23362                 path_constr.data = NULL;
23363         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23364         for (size_t k = 0; k < path_constr.datalen; k++) {
23365                 int64_t path_conv_10 = path_vals[k];
23366                 LDKRouteHop path_conv_10_conv;
23367                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
23368                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
23369                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23370                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23371                 path_constr.data[k] = path_conv_10_conv;
23372         }
23373         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23374         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
23375         CHECK_ACCESS(short_channel_id_ptr);
23376         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
23377         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
23378         LDKRouteParameters retry_conv;
23379         retry_conv.inner = (void*)(retry & (~1));
23380         retry_conv.is_owned = (retry & 1) || (retry == 0);
23381         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
23382         retry_conv = RouteParameters_clone(&retry_conv);
23383         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23384         *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);
23385         int64_t ret_ref = (uintptr_t)ret_copy;
23386         return ret_ref;
23387 }
23388
23389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
23390         LDKThirtyTwoBytes payment_id_ref;
23391         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23392         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23393         LDKThirtyTwoBytes payment_hash_ref;
23394         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23395         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23396         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23397         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
23398         int64_t ret_ref = (uintptr_t)ret_copy;
23399         return ret_ref;
23400 }
23401
23402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
23403         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23404         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
23405         int64_t ret_ref = (uintptr_t)ret_copy;
23406         return ret_ref;
23407 }
23408
23409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
23410         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
23411         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
23412         if (outputs_constr.datalen > 0)
23413                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23414         else
23415                 outputs_constr.data = NULL;
23416         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
23417         for (size_t b = 0; b < outputs_constr.datalen; b++) {
23418                 int64_t outputs_conv_27 = outputs_vals[b];
23419                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
23420                 CHECK_ACCESS(outputs_conv_27_ptr);
23421                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
23422                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
23423                 outputs_constr.data[b] = outputs_conv_27_conv;
23424         }
23425         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
23426         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23427         *ret_copy = Event_spendable_outputs(outputs_constr);
23428         int64_t ret_ref = (uintptr_t)ret_copy;
23429         return ret_ref;
23430 }
23431
23432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
23433         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
23434         CHECK_ACCESS(fee_earned_msat_ptr);
23435         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
23436         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
23437         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23438         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
23439         int64_t ret_ref = (uintptr_t)ret_copy;
23440         return ret_ref;
23441 }
23442
23443 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) {
23444         LDKThirtyTwoBytes channel_id_ref;
23445         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23446         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23447         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
23448         CHECK_ACCESS(reason_ptr);
23449         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
23450         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
23451         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23452         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
23453         int64_t ret_ref = (uintptr_t)ret_copy;
23454         return ret_ref;
23455 }
23456
23457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
23458         LDKThirtyTwoBytes channel_id_ref;
23459         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
23460         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
23461         LDKTransaction transaction_ref;
23462         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
23463         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
23464         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
23465         transaction_ref.data_is_owned = true;
23466         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23467         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
23468         int64_t ret_ref = (uintptr_t)ret_copy;
23469         return ret_ref;
23470 }
23471
23472 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) {
23473         LDKThirtyTwoBytes payment_id_ref;
23474         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
23475         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
23476         LDKThirtyTwoBytes payment_hash_ref;
23477         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
23478         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
23479         LDKCVec_RouteHopZ path_constr;
23480         path_constr.datalen = (*env)->GetArrayLength(env, path);
23481         if (path_constr.datalen > 0)
23482                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
23483         else
23484                 path_constr.data = NULL;
23485         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
23486         for (size_t k = 0; k < path_constr.datalen; k++) {
23487                 int64_t path_conv_10 = path_vals[k];
23488                 LDKRouteHop path_conv_10_conv;
23489                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
23490                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
23491                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
23492                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
23493                 path_constr.data[k] = path_conv_10_conv;
23494         }
23495         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
23496         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23497         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
23498         int64_t ret_ref = (uintptr_t)ret_copy;
23499         return ret_ref;
23500 }
23501
23502 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) {
23503         LDKThirtyTwoBytes temporary_channel_id_ref;
23504         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
23505         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
23506         LDKPublicKey counterparty_node_id_ref;
23507         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
23508         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
23509         LDKChannelTypeFeatures channel_type_conv;
23510         channel_type_conv.inner = (void*)(channel_type & (~1));
23511         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
23512         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
23513         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
23514         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23515         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
23516         int64_t ret_ref = (uintptr_t)ret_copy;
23517         return ret_ref;
23518 }
23519
23520 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
23521         LDKEvent* obj_conv = (LDKEvent*)obj;
23522         LDKCVec_u8Z ret_var = Event_write(obj_conv);
23523         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23524         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23525         CVec_u8Z_free(ret_var);
23526         return ret_arr;
23527 }
23528
23529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23530         LDKu8slice ser_ref;
23531         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23532         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23533         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
23534         *ret_conv = Event_read(ser_ref);
23535         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23536         return (int64_t)ret_conv;
23537 }
23538
23539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23540         if ((this_ptr & 1) != 0) return;
23541         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23542         CHECK_ACCESS(this_ptr_ptr);
23543         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
23544         FREE((void*)this_ptr);
23545         MessageSendEvent_free(this_ptr_conv);
23546 }
23547
23548 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
23549         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23550         *ret_copy = MessageSendEvent_clone(arg);
23551 int64_t ret_ref = (uintptr_t)ret_copy;
23552         return ret_ref;
23553 }
23554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23555         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
23556         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
23557         return ret_conv;
23558 }
23559
23560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23561         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
23562         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23563         *ret_copy = MessageSendEvent_clone(orig_conv);
23564         int64_t ret_ref = (uintptr_t)ret_copy;
23565         return ret_ref;
23566 }
23567
23568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23569         LDKPublicKey node_id_ref;
23570         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23571         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23572         LDKAcceptChannel msg_conv;
23573         msg_conv.inner = (void*)(msg & (~1));
23574         msg_conv.is_owned = (msg & 1) || (msg == 0);
23575         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23576         msg_conv = AcceptChannel_clone(&msg_conv);
23577         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23578         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
23579         int64_t ret_ref = (uintptr_t)ret_copy;
23580         return ret_ref;
23581 }
23582
23583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23584         LDKPublicKey node_id_ref;
23585         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23586         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23587         LDKOpenChannel msg_conv;
23588         msg_conv.inner = (void*)(msg & (~1));
23589         msg_conv.is_owned = (msg & 1) || (msg == 0);
23590         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23591         msg_conv = OpenChannel_clone(&msg_conv);
23592         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23593         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
23594         int64_t ret_ref = (uintptr_t)ret_copy;
23595         return ret_ref;
23596 }
23597
23598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23599         LDKPublicKey node_id_ref;
23600         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23601         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23602         LDKFundingCreated msg_conv;
23603         msg_conv.inner = (void*)(msg & (~1));
23604         msg_conv.is_owned = (msg & 1) || (msg == 0);
23605         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23606         msg_conv = FundingCreated_clone(&msg_conv);
23607         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23608         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
23609         int64_t ret_ref = (uintptr_t)ret_copy;
23610         return ret_ref;
23611 }
23612
23613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23614         LDKPublicKey node_id_ref;
23615         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23616         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23617         LDKFundingSigned msg_conv;
23618         msg_conv.inner = (void*)(msg & (~1));
23619         msg_conv.is_owned = (msg & 1) || (msg == 0);
23620         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23621         msg_conv = FundingSigned_clone(&msg_conv);
23622         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23623         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
23624         int64_t ret_ref = (uintptr_t)ret_copy;
23625         return ret_ref;
23626 }
23627
23628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23629         LDKPublicKey node_id_ref;
23630         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23631         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23632         LDKFundingLocked msg_conv;
23633         msg_conv.inner = (void*)(msg & (~1));
23634         msg_conv.is_owned = (msg & 1) || (msg == 0);
23635         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23636         msg_conv = FundingLocked_clone(&msg_conv);
23637         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23638         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
23639         int64_t ret_ref = (uintptr_t)ret_copy;
23640         return ret_ref;
23641 }
23642
23643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23644         LDKPublicKey node_id_ref;
23645         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23646         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23647         LDKAnnouncementSignatures msg_conv;
23648         msg_conv.inner = (void*)(msg & (~1));
23649         msg_conv.is_owned = (msg & 1) || (msg == 0);
23650         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23651         msg_conv = AnnouncementSignatures_clone(&msg_conv);
23652         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23653         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
23654         int64_t ret_ref = (uintptr_t)ret_copy;
23655         return ret_ref;
23656 }
23657
23658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
23659         LDKPublicKey node_id_ref;
23660         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23661         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23662         LDKCommitmentUpdate updates_conv;
23663         updates_conv.inner = (void*)(updates & (~1));
23664         updates_conv.is_owned = (updates & 1) || (updates == 0);
23665         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
23666         updates_conv = CommitmentUpdate_clone(&updates_conv);
23667         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23668         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
23669         int64_t ret_ref = (uintptr_t)ret_copy;
23670         return ret_ref;
23671 }
23672
23673 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) {
23674         LDKPublicKey node_id_ref;
23675         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23676         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23677         LDKRevokeAndACK msg_conv;
23678         msg_conv.inner = (void*)(msg & (~1));
23679         msg_conv.is_owned = (msg & 1) || (msg == 0);
23680         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23681         msg_conv = RevokeAndACK_clone(&msg_conv);
23682         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23683         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
23684         int64_t ret_ref = (uintptr_t)ret_copy;
23685         return ret_ref;
23686 }
23687
23688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23689         LDKPublicKey node_id_ref;
23690         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23691         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23692         LDKClosingSigned msg_conv;
23693         msg_conv.inner = (void*)(msg & (~1));
23694         msg_conv.is_owned = (msg & 1) || (msg == 0);
23695         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23696         msg_conv = ClosingSigned_clone(&msg_conv);
23697         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23698         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
23699         int64_t ret_ref = (uintptr_t)ret_copy;
23700         return ret_ref;
23701 }
23702
23703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23704         LDKPublicKey node_id_ref;
23705         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23706         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23707         LDKShutdown msg_conv;
23708         msg_conv.inner = (void*)(msg & (~1));
23709         msg_conv.is_owned = (msg & 1) || (msg == 0);
23710         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23711         msg_conv = Shutdown_clone(&msg_conv);
23712         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23713         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
23714         int64_t ret_ref = (uintptr_t)ret_copy;
23715         return ret_ref;
23716 }
23717
23718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23719         LDKPublicKey node_id_ref;
23720         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23721         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23722         LDKChannelReestablish msg_conv;
23723         msg_conv.inner = (void*)(msg & (~1));
23724         msg_conv.is_owned = (msg & 1) || (msg == 0);
23725         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23726         msg_conv = ChannelReestablish_clone(&msg_conv);
23727         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23728         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
23729         int64_t ret_ref = (uintptr_t)ret_copy;
23730         return ret_ref;
23731 }
23732
23733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
23734         LDKChannelAnnouncement msg_conv;
23735         msg_conv.inner = (void*)(msg & (~1));
23736         msg_conv.is_owned = (msg & 1) || (msg == 0);
23737         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23738         msg_conv = ChannelAnnouncement_clone(&msg_conv);
23739         LDKChannelUpdate update_msg_conv;
23740         update_msg_conv.inner = (void*)(update_msg & (~1));
23741         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
23742         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
23743         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
23744         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23745         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
23746         int64_t ret_ref = (uintptr_t)ret_copy;
23747         return ret_ref;
23748 }
23749
23750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
23751         LDKNodeAnnouncement msg_conv;
23752         msg_conv.inner = (void*)(msg & (~1));
23753         msg_conv.is_owned = (msg & 1) || (msg == 0);
23754         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23755         msg_conv = NodeAnnouncement_clone(&msg_conv);
23756         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23757         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
23758         int64_t ret_ref = (uintptr_t)ret_copy;
23759         return ret_ref;
23760 }
23761
23762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
23763         LDKChannelUpdate msg_conv;
23764         msg_conv.inner = (void*)(msg & (~1));
23765         msg_conv.is_owned = (msg & 1) || (msg == 0);
23766         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23767         msg_conv = ChannelUpdate_clone(&msg_conv);
23768         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23769         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
23770         int64_t ret_ref = (uintptr_t)ret_copy;
23771         return ret_ref;
23772 }
23773
23774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
23775         LDKPublicKey node_id_ref;
23776         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23777         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23778         LDKChannelUpdate msg_conv;
23779         msg_conv.inner = (void*)(msg & (~1));
23780         msg_conv.is_owned = (msg & 1) || (msg == 0);
23781         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23782         msg_conv = ChannelUpdate_clone(&msg_conv);
23783         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23784         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
23785         int64_t ret_ref = (uintptr_t)ret_copy;
23786         return ret_ref;
23787 }
23788
23789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
23790         LDKPublicKey node_id_ref;
23791         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23792         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23793         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
23794         CHECK_ACCESS(action_ptr);
23795         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
23796         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
23797         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23798         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
23799         int64_t ret_ref = (uintptr_t)ret_copy;
23800         return ret_ref;
23801 }
23802
23803 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) {
23804         LDKPublicKey node_id_ref;
23805         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23806         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23807         LDKQueryChannelRange msg_conv;
23808         msg_conv.inner = (void*)(msg & (~1));
23809         msg_conv.is_owned = (msg & 1) || (msg == 0);
23810         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23811         msg_conv = QueryChannelRange_clone(&msg_conv);
23812         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23813         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
23814         int64_t ret_ref = (uintptr_t)ret_copy;
23815         return ret_ref;
23816 }
23817
23818 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) {
23819         LDKPublicKey node_id_ref;
23820         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23821         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23822         LDKQueryShortChannelIds msg_conv;
23823         msg_conv.inner = (void*)(msg & (~1));
23824         msg_conv.is_owned = (msg & 1) || (msg == 0);
23825         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23826         msg_conv = QueryShortChannelIds_clone(&msg_conv);
23827         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23828         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
23829         int64_t ret_ref = (uintptr_t)ret_copy;
23830         return ret_ref;
23831 }
23832
23833 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) {
23834         LDKPublicKey node_id_ref;
23835         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23836         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23837         LDKReplyChannelRange msg_conv;
23838         msg_conv.inner = (void*)(msg & (~1));
23839         msg_conv.is_owned = (msg & 1) || (msg == 0);
23840         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23841         msg_conv = ReplyChannelRange_clone(&msg_conv);
23842         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23843         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
23844         int64_t ret_ref = (uintptr_t)ret_copy;
23845         return ret_ref;
23846 }
23847
23848 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) {
23849         LDKPublicKey node_id_ref;
23850         CHECK((*env)->GetArrayLength(env, node_id) == 33);
23851         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
23852         LDKGossipTimestampFilter msg_conv;
23853         msg_conv.inner = (void*)(msg & (~1));
23854         msg_conv.is_owned = (msg & 1) || (msg == 0);
23855         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
23856         msg_conv = GossipTimestampFilter_clone(&msg_conv);
23857         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
23858         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
23859         int64_t ret_ref = (uintptr_t)ret_copy;
23860         return ret_ref;
23861 }
23862
23863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23864         if ((this_ptr & 1) != 0) return;
23865         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23866         CHECK_ACCESS(this_ptr_ptr);
23867         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
23868         FREE((void*)this_ptr);
23869         MessageSendEventsProvider_free(this_ptr_conv);
23870 }
23871
23872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23873         if ((this_ptr & 1) != 0) return;
23874         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23875         CHECK_ACCESS(this_ptr_ptr);
23876         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
23877         FREE((void*)this_ptr);
23878         EventsProvider_free(this_ptr_conv);
23879 }
23880
23881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23882         if ((this_ptr & 1) != 0) return;
23883         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23884         CHECK_ACCESS(this_ptr_ptr);
23885         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
23886         FREE((void*)this_ptr);
23887         EventHandler_free(this_ptr_conv);
23888 }
23889
23890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23891         if ((this_ptr & 1) != 0) return;
23892         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23893         CHECK_ACCESS(this_ptr_ptr);
23894         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
23895         FREE((void*)this_ptr);
23896         APIError_free(this_ptr_conv);
23897 }
23898
23899 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
23900         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23901         *ret_copy = APIError_clone(arg);
23902 int64_t ret_ref = (uintptr_t)ret_copy;
23903         return ret_ref;
23904 }
23905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23906         LDKAPIError* arg_conv = (LDKAPIError*)arg;
23907         int64_t ret_conv = APIError_clone_ptr(arg_conv);
23908         return ret_conv;
23909 }
23910
23911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23912         LDKAPIError* orig_conv = (LDKAPIError*)orig;
23913         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23914         *ret_copy = APIError_clone(orig_conv);
23915         int64_t ret_ref = (uintptr_t)ret_copy;
23916         return ret_ref;
23917 }
23918
23919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
23920         LDKStr err_conv = java_to_owned_str(env, err);
23921         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23922         *ret_copy = APIError_apimisuse_error(err_conv);
23923         int64_t ret_ref = (uintptr_t)ret_copy;
23924         return ret_ref;
23925 }
23926
23927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
23928         LDKStr err_conv = java_to_owned_str(env, err);
23929         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23930         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
23931         int64_t ret_ref = (uintptr_t)ret_copy;
23932         return ret_ref;
23933 }
23934
23935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
23936         LDKStr err_conv = java_to_owned_str(env, err);
23937         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23938         *ret_copy = APIError_route_error(err_conv);
23939         int64_t ret_ref = (uintptr_t)ret_copy;
23940         return ret_ref;
23941 }
23942
23943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
23944         LDKStr err_conv = java_to_owned_str(env, err);
23945         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23946         *ret_copy = APIError_channel_unavailable(err_conv);
23947         int64_t ret_ref = (uintptr_t)ret_copy;
23948         return ret_ref;
23949 }
23950
23951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
23952         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23953         *ret_copy = APIError_monitor_update_failed();
23954         int64_t ret_ref = (uintptr_t)ret_copy;
23955         return ret_ref;
23956 }
23957
23958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
23959         LDKShutdownScript script_conv;
23960         script_conv.inner = (void*)(script & (~1));
23961         script_conv.is_owned = (script & 1) || (script == 0);
23962         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
23963         script_conv = ShutdownScript_clone(&script_conv);
23964         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
23965         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
23966         int64_t ret_ref = (uintptr_t)ret_copy;
23967         return ret_ref;
23968 }
23969
23970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
23971         LDKu8slice msg_ref;
23972         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23973         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23974         unsigned char sk_arr[32];
23975         CHECK((*env)->GetArrayLength(env, sk) == 32);
23976         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
23977         unsigned char (*sk_ref)[32] = &sk_arr;
23978         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
23979         *ret_conv = sign(msg_ref, sk_ref);
23980         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23981         return (int64_t)ret_conv;
23982 }
23983
23984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
23985         LDKu8slice msg_ref;
23986         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23987         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23988         LDKStr sig_conv = java_to_owned_str(env, sig);
23989         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
23990         *ret_conv = recover_pk(msg_ref, sig_conv);
23991         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
23992         return (int64_t)ret_conv;
23993 }
23994
23995 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
23996         LDKu8slice msg_ref;
23997         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
23998         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
23999         LDKStr sig_conv = java_to_owned_str(env, sig);
24000         LDKPublicKey pk_ref;
24001         CHECK((*env)->GetArrayLength(env, pk) == 33);
24002         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
24003         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
24004         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
24005         return ret_conv;
24006 }
24007
24008 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
24009         LDKu8slice hrp_bytes_ref;
24010         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
24011         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
24012         LDKCVec_u5Z data_without_signature_constr;
24013         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
24014         if (data_without_signature_constr.datalen > 0)
24015                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
24016         else
24017                 data_without_signature_constr.data = NULL;
24018         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
24019         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
24020                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
24021                 
24022                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
24023         }
24024         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
24025         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
24026         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24027         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24028         CVec_u8Z_free(ret_var);
24029         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
24030         return ret_arr;
24031 }
24032
24033 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24034         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
24035         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
24036         return ret_conv;
24037 }
24038
24039 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
24040         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
24041         return ret_conv;
24042 }
24043
24044 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
24045         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
24046         return ret_conv;
24047 }
24048
24049 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
24050         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
24051         return ret_conv;
24052 }
24053
24054 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
24055         jclass ret_conv = LDKLevel_to_java(env, Level_info());
24056         return ret_conv;
24057 }
24058
24059 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
24060         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
24061         return ret_conv;
24062 }
24063
24064 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
24065         jclass ret_conv = LDKLevel_to_java(env, Level_error());
24066         return ret_conv;
24067 }
24068
24069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
24070         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
24071         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
24072         jboolean ret_conv = Level_eq(a_conv, b_conv);
24073         return ret_conv;
24074 }
24075
24076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
24077         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
24078         int64_t ret_conv = Level_hash(o_conv);
24079         return ret_conv;
24080 }
24081
24082 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
24083         jclass ret_conv = LDKLevel_to_java(env, Level_max());
24084         return ret_conv;
24085 }
24086
24087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24088         LDKRecord this_obj_conv;
24089         this_obj_conv.inner = (void*)(this_obj & (~1));
24090         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24092         Record_free(this_obj_conv);
24093 }
24094
24095 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
24096         LDKRecord this_ptr_conv;
24097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24098         this_ptr_conv.is_owned = false;
24099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24100         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
24101         return ret_conv;
24102 }
24103
24104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
24105         LDKRecord this_ptr_conv;
24106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24107         this_ptr_conv.is_owned = false;
24108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24109         LDKLevel val_conv = LDKLevel_from_java(env, val);
24110         Record_set_level(&this_ptr_conv, val_conv);
24111 }
24112
24113 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
24114         LDKRecord this_ptr_conv;
24115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24116         this_ptr_conv.is_owned = false;
24117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24118         LDKStr ret_str = Record_get_args(&this_ptr_conv);
24119         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24120         Str_free(ret_str);
24121         return ret_conv;
24122 }
24123
24124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24125         LDKRecord this_ptr_conv;
24126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24127         this_ptr_conv.is_owned = false;
24128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24129         LDKStr val_conv = java_to_owned_str(env, val);
24130         Record_set_args(&this_ptr_conv, val_conv);
24131 }
24132
24133 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
24134         LDKRecord this_ptr_conv;
24135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24136         this_ptr_conv.is_owned = false;
24137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24138         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
24139         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24140         Str_free(ret_str);
24141         return ret_conv;
24142 }
24143
24144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24145         LDKRecord this_ptr_conv;
24146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24147         this_ptr_conv.is_owned = false;
24148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24149         LDKStr val_conv = java_to_owned_str(env, val);
24150         Record_set_module_path(&this_ptr_conv, val_conv);
24151 }
24152
24153 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
24154         LDKRecord this_ptr_conv;
24155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24156         this_ptr_conv.is_owned = false;
24157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24158         LDKStr ret_str = Record_get_file(&this_ptr_conv);
24159         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
24160         Str_free(ret_str);
24161         return ret_conv;
24162 }
24163
24164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
24165         LDKRecord this_ptr_conv;
24166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24167         this_ptr_conv.is_owned = false;
24168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24169         LDKStr val_conv = java_to_owned_str(env, val);
24170         Record_set_file(&this_ptr_conv, val_conv);
24171 }
24172
24173 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
24174         LDKRecord this_ptr_conv;
24175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24176         this_ptr_conv.is_owned = false;
24177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24178         int32_t ret_conv = Record_get_line(&this_ptr_conv);
24179         return ret_conv;
24180 }
24181
24182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24183         LDKRecord this_ptr_conv;
24184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24185         this_ptr_conv.is_owned = false;
24186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24187         Record_set_line(&this_ptr_conv, val);
24188 }
24189
24190 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
24191         LDKRecord ret_var = Record_clone(arg);
24192 int64_t ret_ref = 0;
24193 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24194 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24195 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24196 ret_ref = (uintptr_t)ret_var.inner;
24197 if (ret_var.is_owned) {
24198         ret_ref |= 1;
24199 }
24200         return ret_ref;
24201 }
24202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24203         LDKRecord arg_conv;
24204         arg_conv.inner = (void*)(arg & (~1));
24205         arg_conv.is_owned = false;
24206         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24207         int64_t ret_conv = Record_clone_ptr(&arg_conv);
24208         return ret_conv;
24209 }
24210
24211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24212         LDKRecord orig_conv;
24213         orig_conv.inner = (void*)(orig & (~1));
24214         orig_conv.is_owned = false;
24215         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24216         LDKRecord ret_var = Record_clone(&orig_conv);
24217         int64_t ret_ref = 0;
24218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24221         ret_ref = (uintptr_t)ret_var.inner;
24222         if (ret_var.is_owned) {
24223                 ret_ref |= 1;
24224         }
24225         return ret_ref;
24226 }
24227
24228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24229         if ((this_ptr & 1) != 0) return;
24230         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24231         CHECK_ACCESS(this_ptr_ptr);
24232         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
24233         FREE((void*)this_ptr);
24234         Logger_free(this_ptr_conv);
24235 }
24236
24237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24238         LDKChannelHandshakeConfig this_obj_conv;
24239         this_obj_conv.inner = (void*)(this_obj & (~1));
24240         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24242         ChannelHandshakeConfig_free(this_obj_conv);
24243 }
24244
24245 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
24246         LDKChannelHandshakeConfig this_ptr_conv;
24247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24248         this_ptr_conv.is_owned = false;
24249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24250         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
24251         return ret_conv;
24252 }
24253
24254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24255         LDKChannelHandshakeConfig this_ptr_conv;
24256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24257         this_ptr_conv.is_owned = false;
24258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24259         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
24260 }
24261
24262 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24263         LDKChannelHandshakeConfig this_ptr_conv;
24264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24265         this_ptr_conv.is_owned = false;
24266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24267         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
24268         return ret_conv;
24269 }
24270
24271 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) {
24272         LDKChannelHandshakeConfig this_ptr_conv;
24273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24274         this_ptr_conv.is_owned = false;
24275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24276         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
24277 }
24278
24279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24280         LDKChannelHandshakeConfig this_ptr_conv;
24281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24282         this_ptr_conv.is_owned = false;
24283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24284         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
24285         return ret_conv;
24286 }
24287
24288 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) {
24289         LDKChannelHandshakeConfig this_ptr_conv;
24290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24291         this_ptr_conv.is_owned = false;
24292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24293         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
24294 }
24295
24296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
24297         LDKChannelHandshakeConfig this_ptr_conv;
24298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24299         this_ptr_conv.is_owned = false;
24300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24301         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
24302         return ret_conv;
24303 }
24304
24305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24306         LDKChannelHandshakeConfig this_ptr_conv;
24307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24308         this_ptr_conv.is_owned = false;
24309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24310         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
24311 }
24312
24313 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, jboolean negotiate_scid_privacy_arg) {
24314         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, negotiate_scid_privacy_arg);
24315         int64_t ret_ref = 0;
24316         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24317         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24319         ret_ref = (uintptr_t)ret_var.inner;
24320         if (ret_var.is_owned) {
24321                 ret_ref |= 1;
24322         }
24323         return ret_ref;
24324 }
24325
24326 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
24327         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
24328 int64_t ret_ref = 0;
24329 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24330 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24331 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24332 ret_ref = (uintptr_t)ret_var.inner;
24333 if (ret_var.is_owned) {
24334         ret_ref |= 1;
24335 }
24336         return ret_ref;
24337 }
24338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24339         LDKChannelHandshakeConfig arg_conv;
24340         arg_conv.inner = (void*)(arg & (~1));
24341         arg_conv.is_owned = false;
24342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24343         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
24344         return ret_conv;
24345 }
24346
24347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24348         LDKChannelHandshakeConfig orig_conv;
24349         orig_conv.inner = (void*)(orig & (~1));
24350         orig_conv.is_owned = false;
24351         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24352         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
24353         int64_t ret_ref = 0;
24354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24357         ret_ref = (uintptr_t)ret_var.inner;
24358         if (ret_var.is_owned) {
24359                 ret_ref |= 1;
24360         }
24361         return ret_ref;
24362 }
24363
24364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
24365         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
24366         int64_t ret_ref = 0;
24367         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24368         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24370         ret_ref = (uintptr_t)ret_var.inner;
24371         if (ret_var.is_owned) {
24372                 ret_ref |= 1;
24373         }
24374         return ret_ref;
24375 }
24376
24377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24378         LDKChannelHandshakeLimits this_obj_conv;
24379         this_obj_conv.inner = (void*)(this_obj & (~1));
24380         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24382         ChannelHandshakeLimits_free(this_obj_conv);
24383 }
24384
24385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24386         LDKChannelHandshakeLimits this_ptr_conv;
24387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24388         this_ptr_conv.is_owned = false;
24389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24390         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
24391         return ret_conv;
24392 }
24393
24394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24395         LDKChannelHandshakeLimits this_ptr_conv;
24396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24397         this_ptr_conv.is_owned = false;
24398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24399         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
24400 }
24401
24402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24403         LDKChannelHandshakeLimits this_ptr_conv;
24404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24405         this_ptr_conv.is_owned = false;
24406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24407         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
24408         return ret_conv;
24409 }
24410
24411 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) {
24412         LDKChannelHandshakeLimits this_ptr_conv;
24413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24414         this_ptr_conv.is_owned = false;
24415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24416         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
24417 }
24418
24419 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) {
24420         LDKChannelHandshakeLimits this_ptr_conv;
24421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24422         this_ptr_conv.is_owned = false;
24423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24424         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
24425         return ret_conv;
24426 }
24427
24428 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) {
24429         LDKChannelHandshakeLimits this_ptr_conv;
24430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24431         this_ptr_conv.is_owned = false;
24432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24433         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
24434 }
24435
24436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24437         LDKChannelHandshakeLimits this_ptr_conv;
24438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24439         this_ptr_conv.is_owned = false;
24440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24441         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
24442         return ret_conv;
24443 }
24444
24445 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) {
24446         LDKChannelHandshakeLimits this_ptr_conv;
24447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24448         this_ptr_conv.is_owned = false;
24449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24450         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
24451 }
24452
24453 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
24454         LDKChannelHandshakeLimits this_ptr_conv;
24455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24456         this_ptr_conv.is_owned = false;
24457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24458         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
24459         return ret_conv;
24460 }
24461
24462 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) {
24463         LDKChannelHandshakeLimits this_ptr_conv;
24464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24465         this_ptr_conv.is_owned = false;
24466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24467         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
24468 }
24469
24470 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
24471         LDKChannelHandshakeLimits this_ptr_conv;
24472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24473         this_ptr_conv.is_owned = false;
24474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24475         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
24476         return ret_conv;
24477 }
24478
24479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
24480         LDKChannelHandshakeLimits this_ptr_conv;
24481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24482         this_ptr_conv.is_owned = false;
24483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24484         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
24485 }
24486
24487 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
24488         LDKChannelHandshakeLimits this_ptr_conv;
24489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24490         this_ptr_conv.is_owned = false;
24491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24492         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
24493         return ret_conv;
24494 }
24495
24496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24497         LDKChannelHandshakeLimits this_ptr_conv;
24498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24499         this_ptr_conv.is_owned = false;
24500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24501         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
24502 }
24503
24504 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24505         LDKChannelHandshakeLimits this_ptr_conv;
24506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24507         this_ptr_conv.is_owned = false;
24508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24509         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
24510         return ret_conv;
24511 }
24512
24513 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) {
24514         LDKChannelHandshakeLimits this_ptr_conv;
24515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24516         this_ptr_conv.is_owned = false;
24517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24518         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
24519 }
24520
24521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
24522         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
24523         int64_t ret_ref = 0;
24524         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24525         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24527         ret_ref = (uintptr_t)ret_var.inner;
24528         if (ret_var.is_owned) {
24529                 ret_ref |= 1;
24530         }
24531         return ret_ref;
24532 }
24533
24534 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
24535         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
24536 int64_t ret_ref = 0;
24537 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24538 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24539 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24540 ret_ref = (uintptr_t)ret_var.inner;
24541 if (ret_var.is_owned) {
24542         ret_ref |= 1;
24543 }
24544         return ret_ref;
24545 }
24546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24547         LDKChannelHandshakeLimits arg_conv;
24548         arg_conv.inner = (void*)(arg & (~1));
24549         arg_conv.is_owned = false;
24550         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24551         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
24552         return ret_conv;
24553 }
24554
24555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24556         LDKChannelHandshakeLimits orig_conv;
24557         orig_conv.inner = (void*)(orig & (~1));
24558         orig_conv.is_owned = false;
24559         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24560         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
24561         int64_t ret_ref = 0;
24562         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24563         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24565         ret_ref = (uintptr_t)ret_var.inner;
24566         if (ret_var.is_owned) {
24567                 ret_ref |= 1;
24568         }
24569         return ret_ref;
24570 }
24571
24572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
24573         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
24574         int64_t ret_ref = 0;
24575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24578         ret_ref = (uintptr_t)ret_var.inner;
24579         if (ret_var.is_owned) {
24580                 ret_ref |= 1;
24581         }
24582         return ret_ref;
24583 }
24584
24585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24586         LDKChannelConfig this_obj_conv;
24587         this_obj_conv.inner = (void*)(this_obj & (~1));
24588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24590         ChannelConfig_free(this_obj_conv);
24591 }
24592
24593 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
24594         LDKChannelConfig this_ptr_conv;
24595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24596         this_ptr_conv.is_owned = false;
24597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24598         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
24599         return ret_conv;
24600 }
24601
24602 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) {
24603         LDKChannelConfig this_ptr_conv;
24604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24605         this_ptr_conv.is_owned = false;
24606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24607         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
24608 }
24609
24610 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24611         LDKChannelConfig this_ptr_conv;
24612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24613         this_ptr_conv.is_owned = false;
24614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24615         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
24616         return ret_conv;
24617 }
24618
24619 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) {
24620         LDKChannelConfig this_ptr_conv;
24621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24622         this_ptr_conv.is_owned = false;
24623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24624         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
24625 }
24626
24627 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
24628         LDKChannelConfig this_ptr_conv;
24629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24630         this_ptr_conv.is_owned = false;
24631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24632         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
24633         return ret_conv;
24634 }
24635
24636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
24637         LDKChannelConfig this_ptr_conv;
24638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24639         this_ptr_conv.is_owned = false;
24640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24641         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
24642 }
24643
24644 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
24645         LDKChannelConfig this_ptr_conv;
24646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24647         this_ptr_conv.is_owned = false;
24648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24649         jboolean ret_conv = ChannelConfig_get_announced_channel(&this_ptr_conv);
24650         return ret_conv;
24651 }
24652
24653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24654         LDKChannelConfig this_ptr_conv;
24655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24656         this_ptr_conv.is_owned = false;
24657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24658         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
24659 }
24660
24661 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
24662         LDKChannelConfig this_ptr_conv;
24663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24664         this_ptr_conv.is_owned = false;
24665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24666         jboolean ret_conv = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
24667         return ret_conv;
24668 }
24669
24670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24671         LDKChannelConfig this_ptr_conv;
24672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24673         this_ptr_conv.is_owned = false;
24674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24675         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
24676 }
24677
24678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24679         LDKChannelConfig this_ptr_conv;
24680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24681         this_ptr_conv.is_owned = false;
24682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24683         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
24684         return ret_conv;
24685 }
24686
24687 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) {
24688         LDKChannelConfig this_ptr_conv;
24689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24690         this_ptr_conv.is_owned = false;
24691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24692         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
24693 }
24694
24695 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) {
24696         LDKChannelConfig this_ptr_conv;
24697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24698         this_ptr_conv.is_owned = false;
24699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24700         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
24701         return ret_conv;
24702 }
24703
24704 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) {
24705         LDKChannelConfig this_ptr_conv;
24706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24707         this_ptr_conv.is_owned = false;
24708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24709         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
24710 }
24711
24712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
24713         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
24714         int64_t ret_ref = 0;
24715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24718         ret_ref = (uintptr_t)ret_var.inner;
24719         if (ret_var.is_owned) {
24720                 ret_ref |= 1;
24721         }
24722         return ret_ref;
24723 }
24724
24725 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
24726         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
24727 int64_t ret_ref = 0;
24728 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24729 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24730 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24731 ret_ref = (uintptr_t)ret_var.inner;
24732 if (ret_var.is_owned) {
24733         ret_ref |= 1;
24734 }
24735         return ret_ref;
24736 }
24737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24738         LDKChannelConfig arg_conv;
24739         arg_conv.inner = (void*)(arg & (~1));
24740         arg_conv.is_owned = false;
24741         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24742         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
24743         return ret_conv;
24744 }
24745
24746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24747         LDKChannelConfig orig_conv;
24748         orig_conv.inner = (void*)(orig & (~1));
24749         orig_conv.is_owned = false;
24750         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24751         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
24752         int64_t ret_ref = 0;
24753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24756         ret_ref = (uintptr_t)ret_var.inner;
24757         if (ret_var.is_owned) {
24758                 ret_ref |= 1;
24759         }
24760         return ret_ref;
24761 }
24762
24763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
24764         LDKChannelConfig ret_var = ChannelConfig_default();
24765         int64_t ret_ref = 0;
24766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24769         ret_ref = (uintptr_t)ret_var.inner;
24770         if (ret_var.is_owned) {
24771                 ret_ref |= 1;
24772         }
24773         return ret_ref;
24774 }
24775
24776 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
24777         LDKChannelConfig obj_conv;
24778         obj_conv.inner = (void*)(obj & (~1));
24779         obj_conv.is_owned = false;
24780         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24781         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
24782         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24783         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24784         CVec_u8Z_free(ret_var);
24785         return ret_arr;
24786 }
24787
24788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24789         LDKu8slice ser_ref;
24790         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24791         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24792         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
24793         *ret_conv = ChannelConfig_read(ser_ref);
24794         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24795         return (int64_t)ret_conv;
24796 }
24797
24798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24799         LDKUserConfig this_obj_conv;
24800         this_obj_conv.inner = (void*)(this_obj & (~1));
24801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24803         UserConfig_free(this_obj_conv);
24804 }
24805
24806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
24807         LDKUserConfig this_ptr_conv;
24808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24809         this_ptr_conv.is_owned = false;
24810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24811         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
24812         int64_t ret_ref = 0;
24813         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24814         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24816         ret_ref = (uintptr_t)ret_var.inner;
24817         if (ret_var.is_owned) {
24818                 ret_ref |= 1;
24819         }
24820         return ret_ref;
24821 }
24822
24823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24824         LDKUserConfig this_ptr_conv;
24825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24826         this_ptr_conv.is_owned = false;
24827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24828         LDKChannelHandshakeConfig val_conv;
24829         val_conv.inner = (void*)(val & (~1));
24830         val_conv.is_owned = (val & 1) || (val == 0);
24831         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24832         val_conv = ChannelHandshakeConfig_clone(&val_conv);
24833         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
24834 }
24835
24836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
24837         LDKUserConfig this_ptr_conv;
24838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24839         this_ptr_conv.is_owned = false;
24840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24841         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
24842         int64_t ret_ref = 0;
24843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24846         ret_ref = (uintptr_t)ret_var.inner;
24847         if (ret_var.is_owned) {
24848                 ret_ref |= 1;
24849         }
24850         return ret_ref;
24851 }
24852
24853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24854         LDKUserConfig this_ptr_conv;
24855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24856         this_ptr_conv.is_owned = false;
24857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24858         LDKChannelHandshakeLimits val_conv;
24859         val_conv.inner = (void*)(val & (~1));
24860         val_conv.is_owned = (val & 1) || (val == 0);
24861         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24862         val_conv = ChannelHandshakeLimits_clone(&val_conv);
24863         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
24864 }
24865
24866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
24867         LDKUserConfig this_ptr_conv;
24868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24869         this_ptr_conv.is_owned = false;
24870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24871         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
24872         int64_t ret_ref = 0;
24873         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24874         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24876         ret_ref = (uintptr_t)ret_var.inner;
24877         if (ret_var.is_owned) {
24878                 ret_ref |= 1;
24879         }
24880         return ret_ref;
24881 }
24882
24883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24884         LDKUserConfig this_ptr_conv;
24885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24886         this_ptr_conv.is_owned = false;
24887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24888         LDKChannelConfig val_conv;
24889         val_conv.inner = (void*)(val & (~1));
24890         val_conv.is_owned = (val & 1) || (val == 0);
24891         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24892         val_conv = ChannelConfig_clone(&val_conv);
24893         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
24894 }
24895
24896 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24897         LDKUserConfig this_ptr_conv;
24898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24899         this_ptr_conv.is_owned = false;
24900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24901         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
24902         return ret_conv;
24903 }
24904
24905 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) {
24906         LDKUserConfig this_ptr_conv;
24907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24908         this_ptr_conv.is_owned = false;
24909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24910         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
24911 }
24912
24913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24914         LDKUserConfig this_ptr_conv;
24915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24916         this_ptr_conv.is_owned = false;
24917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24918         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
24919         return ret_conv;
24920 }
24921
24922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24923         LDKUserConfig this_ptr_conv;
24924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24925         this_ptr_conv.is_owned = false;
24926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24927         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
24928 }
24929
24930 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
24931         LDKUserConfig this_ptr_conv;
24932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24933         this_ptr_conv.is_owned = false;
24934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24935         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
24936         return ret_conv;
24937 }
24938
24939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24940         LDKUserConfig this_ptr_conv;
24941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24942         this_ptr_conv.is_owned = false;
24943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24944         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
24945 }
24946
24947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
24948         LDKChannelHandshakeConfig own_channel_config_arg_conv;
24949         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
24950         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
24951         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
24952         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
24953         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
24954         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
24955         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
24956         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
24957         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
24958         LDKChannelConfig channel_options_arg_conv;
24959         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
24960         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
24961         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
24962         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
24963         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
24964         int64_t ret_ref = 0;
24965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24968         ret_ref = (uintptr_t)ret_var.inner;
24969         if (ret_var.is_owned) {
24970                 ret_ref |= 1;
24971         }
24972         return ret_ref;
24973 }
24974
24975 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
24976         LDKUserConfig ret_var = UserConfig_clone(arg);
24977 int64_t ret_ref = 0;
24978 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24979 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24980 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24981 ret_ref = (uintptr_t)ret_var.inner;
24982 if (ret_var.is_owned) {
24983         ret_ref |= 1;
24984 }
24985         return ret_ref;
24986 }
24987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24988         LDKUserConfig arg_conv;
24989         arg_conv.inner = (void*)(arg & (~1));
24990         arg_conv.is_owned = false;
24991         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24992         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
24993         return ret_conv;
24994 }
24995
24996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24997         LDKUserConfig orig_conv;
24998         orig_conv.inner = (void*)(orig & (~1));
24999         orig_conv.is_owned = false;
25000         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25001         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
25002         int64_t ret_ref = 0;
25003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25006         ret_ref = (uintptr_t)ret_var.inner;
25007         if (ret_var.is_owned) {
25008                 ret_ref |= 1;
25009         }
25010         return ret_ref;
25011 }
25012
25013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
25014         LDKUserConfig ret_var = UserConfig_default();
25015         int64_t ret_ref = 0;
25016         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25017         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25019         ret_ref = (uintptr_t)ret_var.inner;
25020         if (ret_var.is_owned) {
25021                 ret_ref |= 1;
25022         }
25023         return ret_ref;
25024 }
25025
25026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25027         LDKBestBlock this_obj_conv;
25028         this_obj_conv.inner = (void*)(this_obj & (~1));
25029         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25031         BestBlock_free(this_obj_conv);
25032 }
25033
25034 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
25035         LDKBestBlock ret_var = BestBlock_clone(arg);
25036 int64_t ret_ref = 0;
25037 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25038 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25039 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25040 ret_ref = (uintptr_t)ret_var.inner;
25041 if (ret_var.is_owned) {
25042         ret_ref |= 1;
25043 }
25044         return ret_ref;
25045 }
25046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25047         LDKBestBlock arg_conv;
25048         arg_conv.inner = (void*)(arg & (~1));
25049         arg_conv.is_owned = false;
25050         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25051         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
25052         return ret_conv;
25053 }
25054
25055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25056         LDKBestBlock orig_conv;
25057         orig_conv.inner = (void*)(orig & (~1));
25058         orig_conv.is_owned = false;
25059         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25060         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
25061         int64_t ret_ref = 0;
25062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25065         ret_ref = (uintptr_t)ret_var.inner;
25066         if (ret_var.is_owned) {
25067                 ret_ref |= 1;
25068         }
25069         return ret_ref;
25070 }
25071
25072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
25073         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
25074         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
25075         int64_t ret_ref = 0;
25076         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25077         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25079         ret_ref = (uintptr_t)ret_var.inner;
25080         if (ret_var.is_owned) {
25081                 ret_ref |= 1;
25082         }
25083         return ret_ref;
25084 }
25085
25086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
25087         LDKThirtyTwoBytes block_hash_ref;
25088         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
25089         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
25090         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
25091         int64_t ret_ref = 0;
25092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25095         ret_ref = (uintptr_t)ret_var.inner;
25096         if (ret_var.is_owned) {
25097                 ret_ref |= 1;
25098         }
25099         return ret_ref;
25100 }
25101
25102 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
25103         LDKBestBlock this_arg_conv;
25104         this_arg_conv.inner = (void*)(this_arg & (~1));
25105         this_arg_conv.is_owned = false;
25106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25107         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25108         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
25109         return ret_arr;
25110 }
25111
25112 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
25113         LDKBestBlock this_arg_conv;
25114         this_arg_conv.inner = (void*)(this_arg & (~1));
25115         this_arg_conv.is_owned = false;
25116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25117         int32_t ret_conv = BestBlock_height(&this_arg_conv);
25118         return ret_conv;
25119 }
25120
25121 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25122         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
25123         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
25124         return ret_conv;
25125 }
25126
25127 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
25128         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
25129         return ret_conv;
25130 }
25131
25132 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
25133         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
25134         return ret_conv;
25135 }
25136
25137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25138         if ((this_ptr & 1) != 0) return;
25139         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25140         CHECK_ACCESS(this_ptr_ptr);
25141         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
25142         FREE((void*)this_ptr);
25143         Access_free(this_ptr_conv);
25144 }
25145
25146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25147         if ((this_ptr & 1) != 0) return;
25148         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25149         CHECK_ACCESS(this_ptr_ptr);
25150         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
25151         FREE((void*)this_ptr);
25152         Listen_free(this_ptr_conv);
25153 }
25154
25155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25156         if ((this_ptr & 1) != 0) return;
25157         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25158         CHECK_ACCESS(this_ptr_ptr);
25159         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
25160         FREE((void*)this_ptr);
25161         Confirm_free(this_ptr_conv);
25162 }
25163
25164 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25165         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
25166         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
25167         return ret_conv;
25168 }
25169
25170 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
25171         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
25172         return ret_conv;
25173 }
25174
25175 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
25176         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
25177         return ret_conv;
25178 }
25179
25180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25181         if ((this_ptr & 1) != 0) return;
25182         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25183         CHECK_ACCESS(this_ptr_ptr);
25184         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
25185         FREE((void*)this_ptr);
25186         Watch_free(this_ptr_conv);
25187 }
25188
25189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25190         if ((this_ptr & 1) != 0) return;
25191         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25192         CHECK_ACCESS(this_ptr_ptr);
25193         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
25194         FREE((void*)this_ptr);
25195         Filter_free(this_ptr_conv);
25196 }
25197
25198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25199         LDKWatchedOutput this_obj_conv;
25200         this_obj_conv.inner = (void*)(this_obj & (~1));
25201         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25203         WatchedOutput_free(this_obj_conv);
25204 }
25205
25206 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25207         LDKWatchedOutput this_ptr_conv;
25208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25209         this_ptr_conv.is_owned = false;
25210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25211         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25212         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
25213         return ret_arr;
25214 }
25215
25216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25217         LDKWatchedOutput this_ptr_conv;
25218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25219         this_ptr_conv.is_owned = false;
25220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25221         LDKThirtyTwoBytes val_ref;
25222         CHECK((*env)->GetArrayLength(env, val) == 32);
25223         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25224         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
25225 }
25226
25227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25228         LDKWatchedOutput this_ptr_conv;
25229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25230         this_ptr_conv.is_owned = false;
25231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25232         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
25233         int64_t ret_ref = 0;
25234         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25235         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25237         ret_ref = (uintptr_t)ret_var.inner;
25238         if (ret_var.is_owned) {
25239                 ret_ref |= 1;
25240         }
25241         return ret_ref;
25242 }
25243
25244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25245         LDKWatchedOutput this_ptr_conv;
25246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25247         this_ptr_conv.is_owned = false;
25248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25249         LDKOutPoint val_conv;
25250         val_conv.inner = (void*)(val & (~1));
25251         val_conv.is_owned = (val & 1) || (val == 0);
25252         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25253         val_conv = OutPoint_clone(&val_conv);
25254         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
25255 }
25256
25257 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25258         LDKWatchedOutput this_ptr_conv;
25259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25260         this_ptr_conv.is_owned = false;
25261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25262         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
25263         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25264         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25265         return ret_arr;
25266 }
25267
25268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25269         LDKWatchedOutput this_ptr_conv;
25270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25271         this_ptr_conv.is_owned = false;
25272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25273         LDKCVec_u8Z val_ref;
25274         val_ref.datalen = (*env)->GetArrayLength(env, val);
25275         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
25276         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
25277         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
25278 }
25279
25280 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) {
25281         LDKThirtyTwoBytes block_hash_arg_ref;
25282         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
25283         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
25284         LDKOutPoint outpoint_arg_conv;
25285         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
25286         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
25287         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
25288         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
25289         LDKCVec_u8Z script_pubkey_arg_ref;
25290         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
25291         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
25292         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
25293         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
25294         int64_t ret_ref = 0;
25295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25298         ret_ref = (uintptr_t)ret_var.inner;
25299         if (ret_var.is_owned) {
25300                 ret_ref |= 1;
25301         }
25302         return ret_ref;
25303 }
25304
25305 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
25306         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
25307 int64_t ret_ref = 0;
25308 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25309 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25310 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25311 ret_ref = (uintptr_t)ret_var.inner;
25312 if (ret_var.is_owned) {
25313         ret_ref |= 1;
25314 }
25315         return ret_ref;
25316 }
25317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25318         LDKWatchedOutput arg_conv;
25319         arg_conv.inner = (void*)(arg & (~1));
25320         arg_conv.is_owned = false;
25321         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25322         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
25323         return ret_conv;
25324 }
25325
25326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25327         LDKWatchedOutput orig_conv;
25328         orig_conv.inner = (void*)(orig & (~1));
25329         orig_conv.is_owned = false;
25330         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25331         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
25332         int64_t ret_ref = 0;
25333         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25334         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25336         ret_ref = (uintptr_t)ret_var.inner;
25337         if (ret_var.is_owned) {
25338                 ret_ref |= 1;
25339         }
25340         return ret_ref;
25341 }
25342
25343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
25344         LDKWatchedOutput o_conv;
25345         o_conv.inner = (void*)(o & (~1));
25346         o_conv.is_owned = false;
25347         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25348         int64_t ret_conv = WatchedOutput_hash(&o_conv);
25349         return ret_conv;
25350 }
25351
25352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25353         if ((this_ptr & 1) != 0) return;
25354         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25355         CHECK_ACCESS(this_ptr_ptr);
25356         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
25357         FREE((void*)this_ptr);
25358         BroadcasterInterface_free(this_ptr_conv);
25359 }
25360
25361 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25362         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
25363         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
25364         return ret_conv;
25365 }
25366
25367 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
25368         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
25369         return ret_conv;
25370 }
25371
25372 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
25373         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
25374         return ret_conv;
25375 }
25376
25377 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
25378         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
25379         return ret_conv;
25380 }
25381
25382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25383         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
25384         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
25385         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
25386         return ret_conv;
25387 }
25388
25389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25390         if ((this_ptr & 1) != 0) return;
25391         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25392         CHECK_ACCESS(this_ptr_ptr);
25393         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
25394         FREE((void*)this_ptr);
25395         FeeEstimator_free(this_ptr_conv);
25396 }
25397
25398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25399         LDKMonitorUpdateId this_obj_conv;
25400         this_obj_conv.inner = (void*)(this_obj & (~1));
25401         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25403         MonitorUpdateId_free(this_obj_conv);
25404 }
25405
25406 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
25407         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
25408 int64_t ret_ref = 0;
25409 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25410 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25411 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25412 ret_ref = (uintptr_t)ret_var.inner;
25413 if (ret_var.is_owned) {
25414         ret_ref |= 1;
25415 }
25416         return ret_ref;
25417 }
25418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25419         LDKMonitorUpdateId arg_conv;
25420         arg_conv.inner = (void*)(arg & (~1));
25421         arg_conv.is_owned = false;
25422         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25423         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
25424         return ret_conv;
25425 }
25426
25427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25428         LDKMonitorUpdateId orig_conv;
25429         orig_conv.inner = (void*)(orig & (~1));
25430         orig_conv.is_owned = false;
25431         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25432         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
25433         int64_t ret_ref = 0;
25434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25437         ret_ref = (uintptr_t)ret_var.inner;
25438         if (ret_var.is_owned) {
25439                 ret_ref |= 1;
25440         }
25441         return ret_ref;
25442 }
25443
25444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
25445         LDKMonitorUpdateId o_conv;
25446         o_conv.inner = (void*)(o & (~1));
25447         o_conv.is_owned = false;
25448         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25449         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
25450         return ret_conv;
25451 }
25452
25453 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25454         LDKMonitorUpdateId a_conv;
25455         a_conv.inner = (void*)(a & (~1));
25456         a_conv.is_owned = false;
25457         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25458         LDKMonitorUpdateId b_conv;
25459         b_conv.inner = (void*)(b & (~1));
25460         b_conv.is_owned = false;
25461         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
25462         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
25463         return ret_conv;
25464 }
25465
25466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25467         if ((this_ptr & 1) != 0) return;
25468         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25469         CHECK_ACCESS(this_ptr_ptr);
25470         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
25471         FREE((void*)this_ptr);
25472         Persist_free(this_ptr_conv);
25473 }
25474
25475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25476         LDKLockedChannelMonitor this_obj_conv;
25477         this_obj_conv.inner = (void*)(this_obj & (~1));
25478         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25480         LockedChannelMonitor_free(this_obj_conv);
25481 }
25482
25483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25484         LDKChainMonitor this_obj_conv;
25485         this_obj_conv.inner = (void*)(this_obj & (~1));
25486         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25488         ChainMonitor_free(this_obj_conv);
25489 }
25490
25491 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) {
25492         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
25493         CHECK_ACCESS(chain_source_ptr);
25494         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
25495         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
25496         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
25497                 // Manually implement clone for Java trait instances
25498                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
25499                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25500                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
25501                 }
25502         }
25503         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
25504         CHECK_ACCESS(broadcaster_ptr);
25505         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
25506         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25507                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25508                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
25509         }
25510         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25511         CHECK_ACCESS(logger_ptr);
25512         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25513         if (logger_conv.free == LDKLogger_JCalls_free) {
25514                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25515                 LDKLogger_JCalls_cloned(&logger_conv);
25516         }
25517         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
25518         CHECK_ACCESS(feeest_ptr);
25519         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
25520         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
25521                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25522                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
25523         }
25524         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
25525         CHECK_ACCESS(persister_ptr);
25526         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
25527         if (persister_conv.free == LDKPersist_JCalls_free) {
25528                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25529                 LDKPersist_JCalls_cloned(&persister_conv);
25530         }
25531         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
25532         int64_t ret_ref = 0;
25533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25536         ret_ref = (uintptr_t)ret_var.inner;
25537         if (ret_var.is_owned) {
25538                 ret_ref |= 1;
25539         }
25540         return ret_ref;
25541 }
25542
25543 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) {
25544         LDKChainMonitor this_arg_conv;
25545         this_arg_conv.inner = (void*)(this_arg & (~1));
25546         this_arg_conv.is_owned = false;
25547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25548         LDKCVec_ChannelDetailsZ ignored_channels_constr;
25549         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
25550         if (ignored_channels_constr.datalen > 0)
25551                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25552         else
25553                 ignored_channels_constr.data = NULL;
25554         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
25555         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
25556                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
25557                 LDKChannelDetails ignored_channels_conv_16_conv;
25558                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
25559                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
25560                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
25561                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
25562                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
25563         }
25564         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
25565         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
25566         int64_tArray ret_arr = NULL;
25567         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25568         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25569         for (size_t j = 0; j < ret_var.datalen; j++) {
25570                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25571                 *ret_conv_9_copy = ret_var.data[j];
25572                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
25573                 ret_arr_ptr[j] = ret_conv_9_ref;
25574         }
25575         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25576         FREE(ret_var.data);
25577         return ret_arr;
25578 }
25579
25580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
25581         LDKChainMonitor this_arg_conv;
25582         this_arg_conv.inner = (void*)(this_arg & (~1));
25583         this_arg_conv.is_owned = false;
25584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25585         LDKOutPoint funding_txo_conv;
25586         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25587         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25588         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25589         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25590         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25591         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
25592         return (int64_t)ret_conv;
25593 }
25594
25595 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
25596         LDKChainMonitor this_arg_conv;
25597         this_arg_conv.inner = (void*)(this_arg & (~1));
25598         this_arg_conv.is_owned = false;
25599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25600         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
25601         int64_tArray ret_arr = NULL;
25602         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
25603         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
25604         for (size_t k = 0; k < ret_var.datalen; k++) {
25605                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
25606                 int64_t ret_conv_10_ref = 0;
25607                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25608                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25609                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
25610                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
25611                 if (ret_conv_10_var.is_owned) {
25612                         ret_conv_10_ref |= 1;
25613                 }
25614                 ret_arr_ptr[k] = ret_conv_10_ref;
25615         }
25616         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
25617         FREE(ret_var.data);
25618         return ret_arr;
25619 }
25620
25621 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) {
25622         LDKChainMonitor this_arg_conv;
25623         this_arg_conv.inner = (void*)(this_arg & (~1));
25624         this_arg_conv.is_owned = false;
25625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25626         LDKOutPoint funding_txo_conv;
25627         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25628         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25629         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25630         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25631         LDKMonitorUpdateId completed_update_id_conv;
25632         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
25633         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
25634         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
25635         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
25636         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25637         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
25638         return (int64_t)ret_conv;
25639 }
25640
25641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
25642         LDKChainMonitor this_arg_conv;
25643         this_arg_conv.inner = (void*)(this_arg & (~1));
25644         this_arg_conv.is_owned = false;
25645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25646         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25647         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
25648         return (int64_t)ret_ret;
25649 }
25650
25651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
25652         LDKChainMonitor this_arg_conv;
25653         this_arg_conv.inner = (void*)(this_arg & (~1));
25654         this_arg_conv.is_owned = false;
25655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25656         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25657         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
25658         return (int64_t)ret_ret;
25659 }
25660
25661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
25662         LDKChainMonitor this_arg_conv;
25663         this_arg_conv.inner = (void*)(this_arg & (~1));
25664         this_arg_conv.is_owned = false;
25665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25666         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
25667         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
25668         return (int64_t)ret_ret;
25669 }
25670
25671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
25672         LDKChainMonitor this_arg_conv;
25673         this_arg_conv.inner = (void*)(this_arg & (~1));
25674         this_arg_conv.is_owned = false;
25675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25676         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25677         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
25678         return (int64_t)ret_ret;
25679 }
25680
25681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25682         LDKChannelMonitorUpdate this_obj_conv;
25683         this_obj_conv.inner = (void*)(this_obj & (~1));
25684         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25686         ChannelMonitorUpdate_free(this_obj_conv);
25687 }
25688
25689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
25690         LDKChannelMonitorUpdate this_ptr_conv;
25691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25692         this_ptr_conv.is_owned = false;
25693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25694         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
25695         return ret_conv;
25696 }
25697
25698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25699         LDKChannelMonitorUpdate this_ptr_conv;
25700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25701         this_ptr_conv.is_owned = false;
25702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25703         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
25704 }
25705
25706 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
25707         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
25708 int64_t ret_ref = 0;
25709 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25710 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25711 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25712 ret_ref = (uintptr_t)ret_var.inner;
25713 if (ret_var.is_owned) {
25714         ret_ref |= 1;
25715 }
25716         return ret_ref;
25717 }
25718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25719         LDKChannelMonitorUpdate arg_conv;
25720         arg_conv.inner = (void*)(arg & (~1));
25721         arg_conv.is_owned = false;
25722         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25723         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
25724         return ret_conv;
25725 }
25726
25727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25728         LDKChannelMonitorUpdate orig_conv;
25729         orig_conv.inner = (void*)(orig & (~1));
25730         orig_conv.is_owned = false;
25731         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25732         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
25733         int64_t ret_ref = 0;
25734         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25735         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25737         ret_ref = (uintptr_t)ret_var.inner;
25738         if (ret_var.is_owned) {
25739                 ret_ref |= 1;
25740         }
25741         return ret_ref;
25742 }
25743
25744 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25745         LDKChannelMonitorUpdate obj_conv;
25746         obj_conv.inner = (void*)(obj & (~1));
25747         obj_conv.is_owned = false;
25748         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25749         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
25750         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25751         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25752         CVec_u8Z_free(ret_var);
25753         return ret_arr;
25754 }
25755
25756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25757         LDKu8slice ser_ref;
25758         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25759         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25760         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
25761         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
25762         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25763         return (int64_t)ret_conv;
25764 }
25765
25766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25767         if ((this_ptr & 1) != 0) return;
25768         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25769         CHECK_ACCESS(this_ptr_ptr);
25770         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
25771         FREE((void*)this_ptr);
25772         MonitorEvent_free(this_ptr_conv);
25773 }
25774
25775 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
25776         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25777         *ret_copy = MonitorEvent_clone(arg);
25778 int64_t ret_ref = (uintptr_t)ret_copy;
25779         return ret_ref;
25780 }
25781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25782         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
25783         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
25784         return ret_conv;
25785 }
25786
25787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25788         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
25789         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25790         *ret_copy = MonitorEvent_clone(orig_conv);
25791         int64_t ret_ref = (uintptr_t)ret_copy;
25792         return ret_ref;
25793 }
25794
25795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
25796         LDKHTLCUpdate a_conv;
25797         a_conv.inner = (void*)(a & (~1));
25798         a_conv.is_owned = (a & 1) || (a == 0);
25799         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25800         a_conv = HTLCUpdate_clone(&a_conv);
25801         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25802         *ret_copy = MonitorEvent_htlcevent(a_conv);
25803         int64_t ret_ref = (uintptr_t)ret_copy;
25804         return ret_ref;
25805 }
25806
25807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
25808         LDKOutPoint a_conv;
25809         a_conv.inner = (void*)(a & (~1));
25810         a_conv.is_owned = (a & 1) || (a == 0);
25811         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25812         a_conv = OutPoint_clone(&a_conv);
25813         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25814         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
25815         int64_t ret_ref = (uintptr_t)ret_copy;
25816         return ret_ref;
25817 }
25818
25819 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) {
25820         LDKOutPoint funding_txo_conv;
25821         funding_txo_conv.inner = (void*)(funding_txo & (~1));
25822         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
25823         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
25824         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
25825         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25826         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
25827         int64_t ret_ref = (uintptr_t)ret_copy;
25828         return ret_ref;
25829 }
25830
25831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
25832         LDKOutPoint a_conv;
25833         a_conv.inner = (void*)(a & (~1));
25834         a_conv.is_owned = (a & 1) || (a == 0);
25835         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25836         a_conv = OutPoint_clone(&a_conv);
25837         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
25838         *ret_copy = MonitorEvent_update_failed(a_conv);
25839         int64_t ret_ref = (uintptr_t)ret_copy;
25840         return ret_ref;
25841 }
25842
25843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
25844         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
25845         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
25846         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25847         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25848         CVec_u8Z_free(ret_var);
25849         return ret_arr;
25850 }
25851
25852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25853         LDKu8slice ser_ref;
25854         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25855         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25856         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
25857         *ret_conv = MonitorEvent_read(ser_ref);
25858         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25859         return (int64_t)ret_conv;
25860 }
25861
25862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25863         LDKHTLCUpdate this_obj_conv;
25864         this_obj_conv.inner = (void*)(this_obj & (~1));
25865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25867         HTLCUpdate_free(this_obj_conv);
25868 }
25869
25870 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
25871         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
25872 int64_t ret_ref = 0;
25873 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25874 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25875 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25876 ret_ref = (uintptr_t)ret_var.inner;
25877 if (ret_var.is_owned) {
25878         ret_ref |= 1;
25879 }
25880         return ret_ref;
25881 }
25882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25883         LDKHTLCUpdate arg_conv;
25884         arg_conv.inner = (void*)(arg & (~1));
25885         arg_conv.is_owned = false;
25886         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25887         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
25888         return ret_conv;
25889 }
25890
25891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25892         LDKHTLCUpdate orig_conv;
25893         orig_conv.inner = (void*)(orig & (~1));
25894         orig_conv.is_owned = false;
25895         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25896         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
25897         int64_t ret_ref = 0;
25898         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25899         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25901         ret_ref = (uintptr_t)ret_var.inner;
25902         if (ret_var.is_owned) {
25903                 ret_ref |= 1;
25904         }
25905         return ret_ref;
25906 }
25907
25908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
25909         LDKHTLCUpdate obj_conv;
25910         obj_conv.inner = (void*)(obj & (~1));
25911         obj_conv.is_owned = false;
25912         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25913         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
25914         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25915         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25916         CVec_u8Z_free(ret_var);
25917         return ret_arr;
25918 }
25919
25920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25921         LDKu8slice ser_ref;
25922         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25923         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25924         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
25925         *ret_conv = HTLCUpdate_read(ser_ref);
25926         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25927         return (int64_t)ret_conv;
25928 }
25929
25930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25931         if ((this_ptr & 1) != 0) return;
25932         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25933         CHECK_ACCESS(this_ptr_ptr);
25934         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
25935         FREE((void*)this_ptr);
25936         Balance_free(this_ptr_conv);
25937 }
25938
25939 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
25940         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25941         *ret_copy = Balance_clone(arg);
25942 int64_t ret_ref = (uintptr_t)ret_copy;
25943         return ret_ref;
25944 }
25945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25946         LDKBalance* arg_conv = (LDKBalance*)arg;
25947         int64_t ret_conv = Balance_clone_ptr(arg_conv);
25948         return ret_conv;
25949 }
25950
25951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25952         LDKBalance* orig_conv = (LDKBalance*)orig;
25953         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25954         *ret_copy = Balance_clone(orig_conv);
25955         int64_t ret_ref = (uintptr_t)ret_copy;
25956         return ret_ref;
25957 }
25958
25959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
25960         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25961         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
25962         int64_t ret_ref = (uintptr_t)ret_copy;
25963         return ret_ref;
25964 }
25965
25966 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) {
25967         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25968         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
25969         int64_t ret_ref = (uintptr_t)ret_copy;
25970         return ret_ref;
25971 }
25972
25973 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) {
25974         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25975         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
25976         int64_t ret_ref = (uintptr_t)ret_copy;
25977         return ret_ref;
25978 }
25979
25980 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) {
25981         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
25982         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
25983         int64_t ret_ref = (uintptr_t)ret_copy;
25984         return ret_ref;
25985 }
25986
25987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
25988         LDKBalance* a_conv = (LDKBalance*)a;
25989         LDKBalance* b_conv = (LDKBalance*)b;
25990         jboolean ret_conv = Balance_eq(a_conv, b_conv);
25991         return ret_conv;
25992 }
25993
25994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25995         LDKChannelMonitor this_obj_conv;
25996         this_obj_conv.inner = (void*)(this_obj & (~1));
25997         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25999         ChannelMonitor_free(this_obj_conv);
26000 }
26001
26002 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
26003         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
26004 int64_t ret_ref = 0;
26005 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26006 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26007 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26008 ret_ref = (uintptr_t)ret_var.inner;
26009 if (ret_var.is_owned) {
26010         ret_ref |= 1;
26011 }
26012         return ret_ref;
26013 }
26014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26015         LDKChannelMonitor arg_conv;
26016         arg_conv.inner = (void*)(arg & (~1));
26017         arg_conv.is_owned = false;
26018         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26019         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
26020         return ret_conv;
26021 }
26022
26023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26024         LDKChannelMonitor orig_conv;
26025         orig_conv.inner = (void*)(orig & (~1));
26026         orig_conv.is_owned = false;
26027         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26028         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
26029         int64_t ret_ref = 0;
26030         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26031         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26033         ret_ref = (uintptr_t)ret_var.inner;
26034         if (ret_var.is_owned) {
26035                 ret_ref |= 1;
26036         }
26037         return ret_ref;
26038 }
26039
26040 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26041         LDKChannelMonitor obj_conv;
26042         obj_conv.inner = (void*)(obj & (~1));
26043         obj_conv.is_owned = false;
26044         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26045         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
26046         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26047         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26048         CVec_u8Z_free(ret_var);
26049         return ret_arr;
26050 }
26051
26052 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) {
26053         LDKChannelMonitor this_arg_conv;
26054         this_arg_conv.inner = (void*)(this_arg & (~1));
26055         this_arg_conv.is_owned = false;
26056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26057         LDKChannelMonitorUpdate updates_conv;
26058         updates_conv.inner = (void*)(updates & (~1));
26059         updates_conv.is_owned = false;
26060         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
26061         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26062         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
26063         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
26064         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26065         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
26066         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
26067         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26068         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
26069         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26070         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
26071         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
26072         return (int64_t)ret_conv;
26073 }
26074
26075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26076         LDKChannelMonitor this_arg_conv;
26077         this_arg_conv.inner = (void*)(this_arg & (~1));
26078         this_arg_conv.is_owned = false;
26079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26080         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
26081         return ret_conv;
26082 }
26083
26084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
26085         LDKChannelMonitor this_arg_conv;
26086         this_arg_conv.inner = (void*)(this_arg & (~1));
26087         this_arg_conv.is_owned = false;
26088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26089         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
26090         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
26091         return ((int64_t)ret_conv);
26092 }
26093
26094 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
26095         LDKChannelMonitor this_arg_conv;
26096         this_arg_conv.inner = (void*)(this_arg & (~1));
26097         this_arg_conv.is_owned = false;
26098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26099         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
26100         int64_tArray ret_arr = NULL;
26101         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26102         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26103         for (size_t o = 0; o < ret_var.datalen; o++) {
26104                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
26105                 *ret_conv_40_conv = ret_var.data[o];
26106                 ret_arr_ptr[o] = ((int64_t)ret_conv_40_conv);
26107         }
26108         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26109         FREE(ret_var.data);
26110         return ret_arr;
26111 }
26112
26113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
26114         LDKChannelMonitor this_arg_conv;
26115         this_arg_conv.inner = (void*)(this_arg & (~1));
26116         this_arg_conv.is_owned = false;
26117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26118         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
26119         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
26120         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
26121         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
26122 }
26123
26124 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
26125         LDKChannelMonitor this_arg_conv;
26126         this_arg_conv.inner = (void*)(this_arg & (~1));
26127         this_arg_conv.is_owned = false;
26128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26129         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
26130         int64_tArray ret_arr = NULL;
26131         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26132         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26133         for (size_t o = 0; o < ret_var.datalen; o++) {
26134                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
26135                 *ret_conv_14_copy = ret_var.data[o];
26136                 int64_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
26137                 ret_arr_ptr[o] = ret_conv_14_ref;
26138         }
26139         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26140         FREE(ret_var.data);
26141         return ret_arr;
26142 }
26143
26144 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
26145         LDKChannelMonitor this_arg_conv;
26146         this_arg_conv.inner = (void*)(this_arg & (~1));
26147         this_arg_conv.is_owned = false;
26148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26149         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
26150         int64_tArray ret_arr = NULL;
26151         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26152         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26153         for (size_t h = 0; h < ret_var.datalen; h++) {
26154                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26155                 *ret_conv_7_copy = ret_var.data[h];
26156                 int64_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
26157                 ret_arr_ptr[h] = ret_conv_7_ref;
26158         }
26159         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26160         FREE(ret_var.data);
26161         return ret_arr;
26162 }
26163
26164 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) {
26165         LDKChannelMonitor this_arg_conv;
26166         this_arg_conv.inner = (void*)(this_arg & (~1));
26167         this_arg_conv.is_owned = false;
26168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26169         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26170         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
26171         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
26172         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
26173         jobjectArray ret_arr = NULL;
26174         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
26175         ;
26176         for (size_t i = 0; i < ret_var.datalen; i++) {
26177                 LDKTransaction ret_conv_8_var = ret_var.data[i];
26178                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
26179                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
26180                 Transaction_free(ret_conv_8_var);
26181                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
26182         }
26183         
26184         FREE(ret_var.data);
26185         return ret_arr;
26186 }
26187
26188 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) {
26189         LDKChannelMonitor this_arg_conv;
26190         this_arg_conv.inner = (void*)(this_arg & (~1));
26191         this_arg_conv.is_owned = false;
26192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26193         unsigned char header_arr[80];
26194         CHECK((*env)->GetArrayLength(env, header) == 80);
26195         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26196         unsigned char (*header_ref)[80] = &header_arr;
26197         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
26198         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
26199         if (txdata_constr.datalen > 0)
26200                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
26201         else
26202                 txdata_constr.data = NULL;
26203         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
26204         for (size_t c = 0; c < txdata_constr.datalen; c++) {
26205                 int64_t txdata_conv_28 = txdata_vals[c];
26206                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
26207                 CHECK_ACCESS(txdata_conv_28_ptr);
26208                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
26209                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
26210                 txdata_constr.data[c] = txdata_conv_28_conv;
26211         }
26212         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
26213         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26214         CHECK_ACCESS(broadcaster_ptr);
26215         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26216         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26217                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26218                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26219         }
26220         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26221         CHECK_ACCESS(fee_estimator_ptr);
26222         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26223         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26224                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26225                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26226         }
26227         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26228         CHECK_ACCESS(logger_ptr);
26229         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26230         if (logger_conv.free == LDKLogger_JCalls_free) {
26231                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26232                 LDKLogger_JCalls_cloned(&logger_conv);
26233         }
26234         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);
26235         int64_tArray ret_arr = NULL;
26236         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26237         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26238         for (size_t n = 0; n < ret_var.datalen; n++) {
26239                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26240                 *ret_conv_39_conv = ret_var.data[n];
26241                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
26242         }
26243         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26244         FREE(ret_var.data);
26245         return ret_arr;
26246 }
26247
26248 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) {
26249         LDKChannelMonitor this_arg_conv;
26250         this_arg_conv.inner = (void*)(this_arg & (~1));
26251         this_arg_conv.is_owned = false;
26252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26253         unsigned char header_arr[80];
26254         CHECK((*env)->GetArrayLength(env, header) == 80);
26255         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26256         unsigned char (*header_ref)[80] = &header_arr;
26257         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26258         CHECK_ACCESS(broadcaster_ptr);
26259         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26260         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26261                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26262                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26263         }
26264         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26265         CHECK_ACCESS(fee_estimator_ptr);
26266         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26267         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26268                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26269                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26270         }
26271         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26272         CHECK_ACCESS(logger_ptr);
26273         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26274         if (logger_conv.free == LDKLogger_JCalls_free) {
26275                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26276                 LDKLogger_JCalls_cloned(&logger_conv);
26277         }
26278         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
26279 }
26280
26281 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) {
26282         LDKChannelMonitor this_arg_conv;
26283         this_arg_conv.inner = (void*)(this_arg & (~1));
26284         this_arg_conv.is_owned = false;
26285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26286         unsigned char header_arr[80];
26287         CHECK((*env)->GetArrayLength(env, header) == 80);
26288         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26289         unsigned char (*header_ref)[80] = &header_arr;
26290         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
26291         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
26292         if (txdata_constr.datalen > 0)
26293                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
26294         else
26295                 txdata_constr.data = NULL;
26296         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
26297         for (size_t c = 0; c < txdata_constr.datalen; c++) {
26298                 int64_t txdata_conv_28 = txdata_vals[c];
26299                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
26300                 CHECK_ACCESS(txdata_conv_28_ptr);
26301                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
26302                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
26303                 txdata_constr.data[c] = txdata_conv_28_conv;
26304         }
26305         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
26306         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26307         CHECK_ACCESS(broadcaster_ptr);
26308         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26309         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26310                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26311                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26312         }
26313         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26314         CHECK_ACCESS(fee_estimator_ptr);
26315         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26316         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26317                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26318                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26319         }
26320         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26321         CHECK_ACCESS(logger_ptr);
26322         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26323         if (logger_conv.free == LDKLogger_JCalls_free) {
26324                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26325                 LDKLogger_JCalls_cloned(&logger_conv);
26326         }
26327         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);
26328         int64_tArray ret_arr = NULL;
26329         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26330         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26331         for (size_t n = 0; n < ret_var.datalen; n++) {
26332                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26333                 *ret_conv_39_conv = ret_var.data[n];
26334                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
26335         }
26336         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26337         FREE(ret_var.data);
26338         return ret_arr;
26339 }
26340
26341 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) {
26342         LDKChannelMonitor this_arg_conv;
26343         this_arg_conv.inner = (void*)(this_arg & (~1));
26344         this_arg_conv.is_owned = false;
26345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26346         unsigned char txid_arr[32];
26347         CHECK((*env)->GetArrayLength(env, txid) == 32);
26348         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
26349         unsigned char (*txid_ref)[32] = &txid_arr;
26350         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26351         CHECK_ACCESS(broadcaster_ptr);
26352         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26353         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26354                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26355                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26356         }
26357         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26358         CHECK_ACCESS(fee_estimator_ptr);
26359         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26360         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26361                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26362                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26363         }
26364         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26365         CHECK_ACCESS(logger_ptr);
26366         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26367         if (logger_conv.free == LDKLogger_JCalls_free) {
26368                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26369                 LDKLogger_JCalls_cloned(&logger_conv);
26370         }
26371         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
26372 }
26373
26374 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) {
26375         LDKChannelMonitor this_arg_conv;
26376         this_arg_conv.inner = (void*)(this_arg & (~1));
26377         this_arg_conv.is_owned = false;
26378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26379         unsigned char header_arr[80];
26380         CHECK((*env)->GetArrayLength(env, header) == 80);
26381         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
26382         unsigned char (*header_ref)[80] = &header_arr;
26383         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
26384         CHECK_ACCESS(broadcaster_ptr);
26385         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
26386         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26387                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26388                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
26389         }
26390         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26391         CHECK_ACCESS(fee_estimator_ptr);
26392         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26393         if (fee_estimator_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(&fee_estimator_conv);
26396         }
26397         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26398         CHECK_ACCESS(logger_ptr);
26399         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26400         if (logger_conv.free == LDKLogger_JCalls_free) {
26401                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26402                 LDKLogger_JCalls_cloned(&logger_conv);
26403         }
26404         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
26405         int64_tArray ret_arr = NULL;
26406         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26407         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26408         for (size_t n = 0; n < ret_var.datalen; n++) {
26409                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
26410                 *ret_conv_39_conv = ret_var.data[n];
26411                 ret_arr_ptr[n] = ((int64_t)ret_conv_39_conv);
26412         }
26413         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26414         FREE(ret_var.data);
26415         return ret_arr;
26416 }
26417
26418 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
26419         LDKChannelMonitor this_arg_conv;
26420         this_arg_conv.inner = (void*)(this_arg & (~1));
26421         this_arg_conv.is_owned = false;
26422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26423         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
26424         jobjectArray ret_arr = NULL;
26425         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
26426         ;
26427         for (size_t i = 0; i < ret_var.datalen; i++) {
26428                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
26429                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
26430                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
26431         }
26432         
26433         FREE(ret_var.data);
26434         return ret_arr;
26435 }
26436
26437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
26438         LDKChannelMonitor this_arg_conv;
26439         this_arg_conv.inner = (void*)(this_arg & (~1));
26440         this_arg_conv.is_owned = false;
26441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26442         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
26443         int64_t ret_ref = 0;
26444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26447         ret_ref = (uintptr_t)ret_var.inner;
26448         if (ret_var.is_owned) {
26449                 ret_ref |= 1;
26450         }
26451         return ret_ref;
26452 }
26453
26454 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
26455         LDKChannelMonitor this_arg_conv;
26456         this_arg_conv.inner = (void*)(this_arg & (~1));
26457         this_arg_conv.is_owned = false;
26458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26459         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
26460         int64_tArray ret_arr = NULL;
26461         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
26462         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
26463         for (size_t j = 0; j < ret_var.datalen; j++) {
26464                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
26465                 *ret_conv_9_copy = ret_var.data[j];
26466                 int64_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
26467                 ret_arr_ptr[j] = ret_conv_9_ref;
26468         }
26469         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
26470         FREE(ret_var.data);
26471         return ret_arr;
26472 }
26473
26474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
26475         LDKu8slice ser_ref;
26476         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26477         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26478         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
26479         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
26480         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
26481         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
26482         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
26483         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26484         return (int64_t)ret_conv;
26485 }
26486
26487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26488         LDKOutPoint this_obj_conv;
26489         this_obj_conv.inner = (void*)(this_obj & (~1));
26490         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26492         OutPoint_free(this_obj_conv);
26493 }
26494
26495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
26496         LDKOutPoint this_ptr_conv;
26497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26498         this_ptr_conv.is_owned = false;
26499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26500         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26501         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
26502         return ret_arr;
26503 }
26504
26505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26506         LDKOutPoint this_ptr_conv;
26507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26508         this_ptr_conv.is_owned = false;
26509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26510         LDKThirtyTwoBytes val_ref;
26511         CHECK((*env)->GetArrayLength(env, val) == 32);
26512         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26513         OutPoint_set_txid(&this_ptr_conv, val_ref);
26514 }
26515
26516 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
26517         LDKOutPoint this_ptr_conv;
26518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26519         this_ptr_conv.is_owned = false;
26520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26521         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
26522         return ret_conv;
26523 }
26524
26525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26526         LDKOutPoint this_ptr_conv;
26527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26528         this_ptr_conv.is_owned = false;
26529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26530         OutPoint_set_index(&this_ptr_conv, val);
26531 }
26532
26533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
26534         LDKThirtyTwoBytes txid_arg_ref;
26535         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
26536         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
26537         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
26538         int64_t ret_ref = 0;
26539         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26540         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26542         ret_ref = (uintptr_t)ret_var.inner;
26543         if (ret_var.is_owned) {
26544                 ret_ref |= 1;
26545         }
26546         return ret_ref;
26547 }
26548
26549 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
26550         LDKOutPoint ret_var = OutPoint_clone(arg);
26551 int64_t ret_ref = 0;
26552 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26553 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26554 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26555 ret_ref = (uintptr_t)ret_var.inner;
26556 if (ret_var.is_owned) {
26557         ret_ref |= 1;
26558 }
26559         return ret_ref;
26560 }
26561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26562         LDKOutPoint arg_conv;
26563         arg_conv.inner = (void*)(arg & (~1));
26564         arg_conv.is_owned = false;
26565         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26566         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
26567         return ret_conv;
26568 }
26569
26570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26571         LDKOutPoint orig_conv;
26572         orig_conv.inner = (void*)(orig & (~1));
26573         orig_conv.is_owned = false;
26574         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26575         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
26576         int64_t ret_ref = 0;
26577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26580         ret_ref = (uintptr_t)ret_var.inner;
26581         if (ret_var.is_owned) {
26582                 ret_ref |= 1;
26583         }
26584         return ret_ref;
26585 }
26586
26587 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26588         LDKOutPoint a_conv;
26589         a_conv.inner = (void*)(a & (~1));
26590         a_conv.is_owned = false;
26591         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
26592         LDKOutPoint b_conv;
26593         b_conv.inner = (void*)(b & (~1));
26594         b_conv.is_owned = false;
26595         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
26596         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
26597         return ret_conv;
26598 }
26599
26600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
26601         LDKOutPoint o_conv;
26602         o_conv.inner = (void*)(o & (~1));
26603         o_conv.is_owned = false;
26604         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26605         int64_t ret_conv = OutPoint_hash(&o_conv);
26606         return ret_conv;
26607 }
26608
26609 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
26610         LDKOutPoint this_arg_conv;
26611         this_arg_conv.inner = (void*)(this_arg & (~1));
26612         this_arg_conv.is_owned = false;
26613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26614         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26615         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
26616         return ret_arr;
26617 }
26618
26619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
26620         LDKOutPoint obj_conv;
26621         obj_conv.inner = (void*)(obj & (~1));
26622         obj_conv.is_owned = false;
26623         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26624         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
26625         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26626         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26627         CVec_u8Z_free(ret_var);
26628         return ret_arr;
26629 }
26630
26631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26632         LDKu8slice ser_ref;
26633         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26634         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26635         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
26636         *ret_conv = OutPoint_read(ser_ref);
26637         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26638         return (int64_t)ret_conv;
26639 }
26640
26641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26642         LDKDelayedPaymentOutputDescriptor this_obj_conv;
26643         this_obj_conv.inner = (void*)(this_obj & (~1));
26644         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26646         DelayedPaymentOutputDescriptor_free(this_obj_conv);
26647 }
26648
26649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26650         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26652         this_ptr_conv.is_owned = false;
26653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26654         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
26655         int64_t ret_ref = 0;
26656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26659         ret_ref = (uintptr_t)ret_var.inner;
26660         if (ret_var.is_owned) {
26661                 ret_ref |= 1;
26662         }
26663         return ret_ref;
26664 }
26665
26666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26667         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26669         this_ptr_conv.is_owned = false;
26670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26671         LDKOutPoint val_conv;
26672         val_conv.inner = (void*)(val & (~1));
26673         val_conv.is_owned = (val & 1) || (val == 0);
26674         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26675         val_conv = OutPoint_clone(&val_conv);
26676         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
26677 }
26678
26679 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26680         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26682         this_ptr_conv.is_owned = false;
26683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26684         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26685         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
26686         return ret_arr;
26687 }
26688
26689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26690         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26692         this_ptr_conv.is_owned = false;
26693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26694         LDKPublicKey val_ref;
26695         CHECK((*env)->GetArrayLength(env, val) == 33);
26696         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26697         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
26698 }
26699
26700 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26701         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26703         this_ptr_conv.is_owned = false;
26704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26705         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
26706         return ret_conv;
26707 }
26708
26709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26710         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26712         this_ptr_conv.is_owned = false;
26713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26714         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
26715 }
26716
26717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26718         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26720         this_ptr_conv.is_owned = false;
26721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26722         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26723         CHECK_ACCESS(val_ptr);
26724         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
26725         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
26726         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
26727 }
26728
26729 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26730         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26732         this_ptr_conv.is_owned = false;
26733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26734         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26735         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
26736         return ret_arr;
26737 }
26738
26739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26740         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26742         this_ptr_conv.is_owned = false;
26743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26744         LDKPublicKey val_ref;
26745         CHECK((*env)->GetArrayLength(env, val) == 33);
26746         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26747         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
26748 }
26749
26750 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26751         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26753         this_ptr_conv.is_owned = false;
26754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26755         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26756         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
26757         return ret_arr;
26758 }
26759
26760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26761         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26763         this_ptr_conv.is_owned = false;
26764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26765         LDKThirtyTwoBytes val_ref;
26766         CHECK((*env)->GetArrayLength(env, val) == 32);
26767         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26768         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
26769 }
26770
26771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26772         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26774         this_ptr_conv.is_owned = false;
26775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26776         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
26777         return ret_conv;
26778 }
26779
26780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26781         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
26782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26783         this_ptr_conv.is_owned = false;
26784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26785         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
26786 }
26787
26788 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) {
26789         LDKOutPoint outpoint_arg_conv;
26790         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26791         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26792         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26793         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26794         LDKPublicKey per_commitment_point_arg_ref;
26795         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
26796         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
26797         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
26798         CHECK_ACCESS(output_arg_ptr);
26799         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
26800         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
26801         LDKPublicKey revocation_pubkey_arg_ref;
26802         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
26803         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
26804         LDKThirtyTwoBytes channel_keys_id_arg_ref;
26805         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
26806         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
26807         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);
26808         int64_t ret_ref = 0;
26809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26812         ret_ref = (uintptr_t)ret_var.inner;
26813         if (ret_var.is_owned) {
26814                 ret_ref |= 1;
26815         }
26816         return ret_ref;
26817 }
26818
26819 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
26820         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
26821 int64_t ret_ref = 0;
26822 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26823 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26824 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26825 ret_ref = (uintptr_t)ret_var.inner;
26826 if (ret_var.is_owned) {
26827         ret_ref |= 1;
26828 }
26829         return ret_ref;
26830 }
26831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26832         LDKDelayedPaymentOutputDescriptor arg_conv;
26833         arg_conv.inner = (void*)(arg & (~1));
26834         arg_conv.is_owned = false;
26835         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26836         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
26837         return ret_conv;
26838 }
26839
26840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26841         LDKDelayedPaymentOutputDescriptor orig_conv;
26842         orig_conv.inner = (void*)(orig & (~1));
26843         orig_conv.is_owned = false;
26844         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26845         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
26846         int64_t ret_ref = 0;
26847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26850         ret_ref = (uintptr_t)ret_var.inner;
26851         if (ret_var.is_owned) {
26852                 ret_ref |= 1;
26853         }
26854         return ret_ref;
26855 }
26856
26857 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
26858         LDKDelayedPaymentOutputDescriptor obj_conv;
26859         obj_conv.inner = (void*)(obj & (~1));
26860         obj_conv.is_owned = false;
26861         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26862         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
26863         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26864         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26865         CVec_u8Z_free(ret_var);
26866         return ret_arr;
26867 }
26868
26869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26870         LDKu8slice ser_ref;
26871         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26872         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26873         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
26874         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
26875         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26876         return (int64_t)ret_conv;
26877 }
26878
26879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26880         LDKStaticPaymentOutputDescriptor this_obj_conv;
26881         this_obj_conv.inner = (void*)(this_obj & (~1));
26882         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26884         StaticPaymentOutputDescriptor_free(this_obj_conv);
26885 }
26886
26887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26888         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26890         this_ptr_conv.is_owned = false;
26891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26892         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
26893         int64_t ret_ref = 0;
26894         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26895         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26897         ret_ref = (uintptr_t)ret_var.inner;
26898         if (ret_var.is_owned) {
26899                 ret_ref |= 1;
26900         }
26901         return ret_ref;
26902 }
26903
26904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26905         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26907         this_ptr_conv.is_owned = false;
26908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26909         LDKOutPoint val_conv;
26910         val_conv.inner = (void*)(val & (~1));
26911         val_conv.is_owned = (val & 1) || (val == 0);
26912         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26913         val_conv = OutPoint_clone(&val_conv);
26914         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
26915 }
26916
26917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26918         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26920         this_ptr_conv.is_owned = false;
26921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26922         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26923         CHECK_ACCESS(val_ptr);
26924         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
26925         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
26926         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
26927 }
26928
26929 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26930         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26932         this_ptr_conv.is_owned = false;
26933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26934         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26935         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
26936         return ret_arr;
26937 }
26938
26939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26940         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26942         this_ptr_conv.is_owned = false;
26943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26944         LDKThirtyTwoBytes val_ref;
26945         CHECK((*env)->GetArrayLength(env, val) == 32);
26946         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26947         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
26948 }
26949
26950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26951         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26953         this_ptr_conv.is_owned = false;
26954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26955         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
26956         return ret_conv;
26957 }
26958
26959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26960         LDKStaticPaymentOutputDescriptor this_ptr_conv;
26961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26962         this_ptr_conv.is_owned = false;
26963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26964         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
26965 }
26966
26967 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) {
26968         LDKOutPoint outpoint_arg_conv;
26969         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
26970         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
26971         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
26972         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
26973         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
26974         CHECK_ACCESS(output_arg_ptr);
26975         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
26976         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
26977         LDKThirtyTwoBytes channel_keys_id_arg_ref;
26978         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
26979         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
26980         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
26981         int64_t ret_ref = 0;
26982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26985         ret_ref = (uintptr_t)ret_var.inner;
26986         if (ret_var.is_owned) {
26987                 ret_ref |= 1;
26988         }
26989         return ret_ref;
26990 }
26991
26992 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
26993         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
26994 int64_t ret_ref = 0;
26995 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26996 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26997 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26998 ret_ref = (uintptr_t)ret_var.inner;
26999 if (ret_var.is_owned) {
27000         ret_ref |= 1;
27001 }
27002         return ret_ref;
27003 }
27004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27005         LDKStaticPaymentOutputDescriptor arg_conv;
27006         arg_conv.inner = (void*)(arg & (~1));
27007         arg_conv.is_owned = false;
27008         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27009         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
27010         return ret_conv;
27011 }
27012
27013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27014         LDKStaticPaymentOutputDescriptor orig_conv;
27015         orig_conv.inner = (void*)(orig & (~1));
27016         orig_conv.is_owned = false;
27017         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27018         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
27019         int64_t ret_ref = 0;
27020         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27021         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27023         ret_ref = (uintptr_t)ret_var.inner;
27024         if (ret_var.is_owned) {
27025                 ret_ref |= 1;
27026         }
27027         return ret_ref;
27028 }
27029
27030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27031         LDKStaticPaymentOutputDescriptor obj_conv;
27032         obj_conv.inner = (void*)(obj & (~1));
27033         obj_conv.is_owned = false;
27034         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27035         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
27036         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27037         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27038         CVec_u8Z_free(ret_var);
27039         return ret_arr;
27040 }
27041
27042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27043         LDKu8slice ser_ref;
27044         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27045         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27046         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
27047         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
27048         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27049         return (int64_t)ret_conv;
27050 }
27051
27052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27053         if ((this_ptr & 1) != 0) return;
27054         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27055         CHECK_ACCESS(this_ptr_ptr);
27056         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
27057         FREE((void*)this_ptr);
27058         SpendableOutputDescriptor_free(this_ptr_conv);
27059 }
27060
27061 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
27062         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27063         *ret_copy = SpendableOutputDescriptor_clone(arg);
27064 int64_t ret_ref = (uintptr_t)ret_copy;
27065         return ret_ref;
27066 }
27067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27068         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
27069         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
27070         return ret_conv;
27071 }
27072
27073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27074         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
27075         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27076         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
27077         int64_t ret_ref = (uintptr_t)ret_copy;
27078         return ret_ref;
27079 }
27080
27081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
27082         LDKOutPoint outpoint_conv;
27083         outpoint_conv.inner = (void*)(outpoint & (~1));
27084         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
27085         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
27086         outpoint_conv = OutPoint_clone(&outpoint_conv);
27087         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
27088         CHECK_ACCESS(output_ptr);
27089         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
27090         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
27091         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27092         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
27093         int64_t ret_ref = (uintptr_t)ret_copy;
27094         return ret_ref;
27095 }
27096
27097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27098         LDKDelayedPaymentOutputDescriptor a_conv;
27099         a_conv.inner = (void*)(a & (~1));
27100         a_conv.is_owned = (a & 1) || (a == 0);
27101         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27102         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
27103         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27104         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
27105         int64_t ret_ref = (uintptr_t)ret_copy;
27106         return ret_ref;
27107 }
27108
27109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
27110         LDKStaticPaymentOutputDescriptor a_conv;
27111         a_conv.inner = (void*)(a & (~1));
27112         a_conv.is_owned = (a & 1) || (a == 0);
27113         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27114         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
27115         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
27116         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
27117         int64_t ret_ref = (uintptr_t)ret_copy;
27118         return ret_ref;
27119 }
27120
27121 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
27122         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
27123         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
27124         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27125         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27126         CVec_u8Z_free(ret_var);
27127         return ret_arr;
27128 }
27129
27130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27131         LDKu8slice ser_ref;
27132         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27133         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27134         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
27135         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
27136         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27137         return (int64_t)ret_conv;
27138 }
27139
27140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27141         if ((this_ptr & 1) != 0) return;
27142         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27143         CHECK_ACCESS(this_ptr_ptr);
27144         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
27145         FREE((void*)this_ptr);
27146         BaseSign_free(this_ptr_conv);
27147 }
27148
27149 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
27150         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27151         *ret_ret = Sign_clone(arg);
27152         return (int64_t)ret_ret;
27153 }
27154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27155         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
27156         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
27157         LDKSign* arg_conv = (LDKSign*)arg_ptr;
27158         int64_t ret_conv = Sign_clone_ptr(arg_conv);
27159         return ret_conv;
27160 }
27161
27162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27163         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
27164         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
27165         LDKSign* orig_conv = (LDKSign*)orig_ptr;
27166         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27167         *ret_ret = Sign_clone(orig_conv);
27168         return (int64_t)ret_ret;
27169 }
27170
27171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27172         if ((this_ptr & 1) != 0) return;
27173         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27174         CHECK_ACCESS(this_ptr_ptr);
27175         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
27176         FREE((void*)this_ptr);
27177         Sign_free(this_ptr_conv);
27178 }
27179
27180 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27181         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
27182         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
27183         return ret_conv;
27184 }
27185
27186 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
27187         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
27188         return ret_conv;
27189 }
27190
27191 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
27192         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
27193         return ret_conv;
27194 }
27195
27196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27197         if ((this_ptr & 1) != 0) return;
27198         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27199         CHECK_ACCESS(this_ptr_ptr);
27200         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
27201         FREE((void*)this_ptr);
27202         KeysInterface_free(this_ptr_conv);
27203 }
27204
27205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27206         LDKInMemorySigner this_obj_conv;
27207         this_obj_conv.inner = (void*)(this_obj & (~1));
27208         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27210         InMemorySigner_free(this_obj_conv);
27211 }
27212
27213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27214         LDKInMemorySigner this_ptr_conv;
27215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27216         this_ptr_conv.is_owned = false;
27217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27218         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27219         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
27220         return ret_arr;
27221 }
27222
27223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27224         LDKInMemorySigner this_ptr_conv;
27225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27226         this_ptr_conv.is_owned = false;
27227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27228         LDKSecretKey val_ref;
27229         CHECK((*env)->GetArrayLength(env, val) == 32);
27230         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27231         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
27232 }
27233
27234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27235         LDKInMemorySigner this_ptr_conv;
27236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27237         this_ptr_conv.is_owned = false;
27238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27239         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27240         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
27241         return ret_arr;
27242 }
27243
27244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27245         LDKInMemorySigner this_ptr_conv;
27246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27247         this_ptr_conv.is_owned = false;
27248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27249         LDKSecretKey val_ref;
27250         CHECK((*env)->GetArrayLength(env, val) == 32);
27251         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27252         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
27253 }
27254
27255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27256         LDKInMemorySigner this_ptr_conv;
27257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27258         this_ptr_conv.is_owned = false;
27259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27260         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27261         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
27262         return ret_arr;
27263 }
27264
27265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27266         LDKInMemorySigner this_ptr_conv;
27267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27268         this_ptr_conv.is_owned = false;
27269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27270         LDKSecretKey val_ref;
27271         CHECK((*env)->GetArrayLength(env, val) == 32);
27272         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27273         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
27274 }
27275
27276 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27277         LDKInMemorySigner this_ptr_conv;
27278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27279         this_ptr_conv.is_owned = false;
27280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27281         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27282         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
27283         return ret_arr;
27284 }
27285
27286 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) {
27287         LDKInMemorySigner this_ptr_conv;
27288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27289         this_ptr_conv.is_owned = false;
27290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27291         LDKSecretKey val_ref;
27292         CHECK((*env)->GetArrayLength(env, val) == 32);
27293         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27294         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
27295 }
27296
27297 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
27298         LDKInMemorySigner this_ptr_conv;
27299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27300         this_ptr_conv.is_owned = false;
27301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27302         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27303         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
27304         return ret_arr;
27305 }
27306
27307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27308         LDKInMemorySigner this_ptr_conv;
27309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27310         this_ptr_conv.is_owned = false;
27311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27312         LDKSecretKey val_ref;
27313         CHECK((*env)->GetArrayLength(env, val) == 32);
27314         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
27315         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
27316 }
27317
27318 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
27319         LDKInMemorySigner this_ptr_conv;
27320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27321         this_ptr_conv.is_owned = false;
27322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27323         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27324         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
27325         return ret_arr;
27326 }
27327
27328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27329         LDKInMemorySigner this_ptr_conv;
27330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27331         this_ptr_conv.is_owned = false;
27332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27333         LDKThirtyTwoBytes val_ref;
27334         CHECK((*env)->GetArrayLength(env, val) == 32);
27335         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27336         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
27337 }
27338
27339 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
27340         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
27341 int64_t ret_ref = 0;
27342 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27343 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27344 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27345 ret_ref = (uintptr_t)ret_var.inner;
27346 if (ret_var.is_owned) {
27347         ret_ref |= 1;
27348 }
27349         return ret_ref;
27350 }
27351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27352         LDKInMemorySigner arg_conv;
27353         arg_conv.inner = (void*)(arg & (~1));
27354         arg_conv.is_owned = false;
27355         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27356         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
27357         return ret_conv;
27358 }
27359
27360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27361         LDKInMemorySigner orig_conv;
27362         orig_conv.inner = (void*)(orig & (~1));
27363         orig_conv.is_owned = false;
27364         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27365         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
27366         int64_t ret_ref = 0;
27367         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27368         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27370         ret_ref = (uintptr_t)ret_var.inner;
27371         if (ret_var.is_owned) {
27372                 ret_ref |= 1;
27373         }
27374         return ret_ref;
27375 }
27376
27377 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) {
27378         LDKSecretKey node_secret_ref;
27379         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
27380         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
27381         LDKSecretKey funding_key_ref;
27382         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
27383         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
27384         LDKSecretKey revocation_base_key_ref;
27385         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
27386         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
27387         LDKSecretKey payment_key_ref;
27388         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
27389         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
27390         LDKSecretKey delayed_payment_base_key_ref;
27391         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
27392         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
27393         LDKSecretKey htlc_base_key_ref;
27394         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
27395         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
27396         LDKThirtyTwoBytes commitment_seed_ref;
27397         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
27398         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
27399         LDKThirtyTwoBytes channel_keys_id_ref;
27400         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
27401         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
27402         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);
27403         int64_t ret_ref = 0;
27404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27407         ret_ref = (uintptr_t)ret_var.inner;
27408         if (ret_var.is_owned) {
27409                 ret_ref |= 1;
27410         }
27411         return ret_ref;
27412 }
27413
27414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
27415         LDKInMemorySigner this_arg_conv;
27416         this_arg_conv.inner = (void*)(this_arg & (~1));
27417         this_arg_conv.is_owned = false;
27418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27419         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
27420         int64_t ret_ref = 0;
27421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27424         ret_ref = (uintptr_t)ret_var.inner;
27425         if (ret_var.is_owned) {
27426                 ret_ref |= 1;
27427         }
27428         return ret_ref;
27429 }
27430
27431 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
27432         LDKInMemorySigner this_arg_conv;
27433         this_arg_conv.inner = (void*)(this_arg & (~1));
27434         this_arg_conv.is_owned = false;
27435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27436         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
27437         return ret_conv;
27438 }
27439
27440 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
27441         LDKInMemorySigner this_arg_conv;
27442         this_arg_conv.inner = (void*)(this_arg & (~1));
27443         this_arg_conv.is_owned = false;
27444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27445         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
27446         return ret_conv;
27447 }
27448
27449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
27450         LDKInMemorySigner this_arg_conv;
27451         this_arg_conv.inner = (void*)(this_arg & (~1));
27452         this_arg_conv.is_owned = false;
27453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27454         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
27455         return ret_conv;
27456 }
27457
27458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
27459         LDKInMemorySigner this_arg_conv;
27460         this_arg_conv.inner = (void*)(this_arg & (~1));
27461         this_arg_conv.is_owned = false;
27462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27463         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
27464         int64_t ret_ref = 0;
27465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27468         ret_ref = (uintptr_t)ret_var.inner;
27469         if (ret_var.is_owned) {
27470                 ret_ref |= 1;
27471         }
27472         return ret_ref;
27473 }
27474
27475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
27476         LDKInMemorySigner this_arg_conv;
27477         this_arg_conv.inner = (void*)(this_arg & (~1));
27478         this_arg_conv.is_owned = false;
27479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27480         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
27481         int64_t ret_ref = 0;
27482         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27483         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27485         ret_ref = (uintptr_t)ret_var.inner;
27486         if (ret_var.is_owned) {
27487                 ret_ref |= 1;
27488         }
27489         return ret_ref;
27490 }
27491
27492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
27493         LDKInMemorySigner this_arg_conv;
27494         this_arg_conv.inner = (void*)(this_arg & (~1));
27495         this_arg_conv.is_owned = false;
27496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27497         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
27498         return ret_conv;
27499 }
27500
27501 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) {
27502         LDKInMemorySigner this_arg_conv;
27503         this_arg_conv.inner = (void*)(this_arg & (~1));
27504         this_arg_conv.is_owned = false;
27505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27506         LDKTransaction spend_tx_ref;
27507         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
27508         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
27509         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
27510         spend_tx_ref.data_is_owned = true;
27511         LDKStaticPaymentOutputDescriptor descriptor_conv;
27512         descriptor_conv.inner = (void*)(descriptor & (~1));
27513         descriptor_conv.is_owned = false;
27514         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
27515         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
27516         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
27517         return (int64_t)ret_conv;
27518 }
27519
27520 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) {
27521         LDKInMemorySigner this_arg_conv;
27522         this_arg_conv.inner = (void*)(this_arg & (~1));
27523         this_arg_conv.is_owned = false;
27524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27525         LDKTransaction spend_tx_ref;
27526         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
27527         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
27528         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
27529         spend_tx_ref.data_is_owned = true;
27530         LDKDelayedPaymentOutputDescriptor descriptor_conv;
27531         descriptor_conv.inner = (void*)(descriptor & (~1));
27532         descriptor_conv.is_owned = false;
27533         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
27534         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
27535         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
27536         return (int64_t)ret_conv;
27537 }
27538
27539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
27540         LDKInMemorySigner this_arg_conv;
27541         this_arg_conv.inner = (void*)(this_arg & (~1));
27542         this_arg_conv.is_owned = false;
27543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27544         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
27545         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
27546         return (int64_t)ret_ret;
27547 }
27548
27549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
27550         LDKInMemorySigner this_arg_conv;
27551         this_arg_conv.inner = (void*)(this_arg & (~1));
27552         this_arg_conv.is_owned = false;
27553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27554         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
27555         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
27556         return (int64_t)ret_ret;
27557 }
27558
27559 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
27560         LDKInMemorySigner obj_conv;
27561         obj_conv.inner = (void*)(obj & (~1));
27562         obj_conv.is_owned = false;
27563         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27564         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
27565         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27566         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27567         CVec_u8Z_free(ret_var);
27568         return ret_arr;
27569 }
27570
27571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
27572         LDKu8slice ser_ref;
27573         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27574         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27575         LDKSecretKey arg_ref;
27576         CHECK((*env)->GetArrayLength(env, arg) == 32);
27577         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
27578         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
27579         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
27580         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27581         return (int64_t)ret_conv;
27582 }
27583
27584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27585         LDKKeysManager this_obj_conv;
27586         this_obj_conv.inner = (void*)(this_obj & (~1));
27587         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27589         KeysManager_free(this_obj_conv);
27590 }
27591
27592 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) {
27593         unsigned char seed_arr[32];
27594         CHECK((*env)->GetArrayLength(env, seed) == 32);
27595         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27596         unsigned char (*seed_ref)[32] = &seed_arr;
27597         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
27598         int64_t ret_ref = 0;
27599         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27600         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27602         ret_ref = (uintptr_t)ret_var.inner;
27603         if (ret_var.is_owned) {
27604                 ret_ref |= 1;
27605         }
27606         return ret_ref;
27607 }
27608
27609 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) {
27610         LDKKeysManager this_arg_conv;
27611         this_arg_conv.inner = (void*)(this_arg & (~1));
27612         this_arg_conv.is_owned = false;
27613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27614         unsigned char params_arr[32];
27615         CHECK((*env)->GetArrayLength(env, params) == 32);
27616         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27617         unsigned char (*params_ref)[32] = &params_arr;
27618         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27619         int64_t ret_ref = 0;
27620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27623         ret_ref = (uintptr_t)ret_var.inner;
27624         if (ret_var.is_owned) {
27625                 ret_ref |= 1;
27626         }
27627         return ret_ref;
27628 }
27629
27630 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) {
27631         LDKKeysManager this_arg_conv;
27632         this_arg_conv.inner = (void*)(this_arg & (~1));
27633         this_arg_conv.is_owned = false;
27634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27635         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27636         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27637         if (descriptors_constr.datalen > 0)
27638                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27639         else
27640                 descriptors_constr.data = NULL;
27641         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27642         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27643                 int64_t descriptors_conv_27 = descriptors_vals[b];
27644                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
27645                 CHECK_ACCESS(descriptors_conv_27_ptr);
27646                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27647                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
27648                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27649         }
27650         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27651         LDKCVec_TxOutZ outputs_constr;
27652         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27653         if (outputs_constr.datalen > 0)
27654                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27655         else
27656                 outputs_constr.data = NULL;
27657         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27658         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27659                 int64_t outputs_conv_7 = outputs_vals[h];
27660                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
27661                 CHECK_ACCESS(outputs_conv_7_ptr);
27662                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27663                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
27664                 outputs_constr.data[h] = outputs_conv_7_conv;
27665         }
27666         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27667         LDKCVec_u8Z change_destination_script_ref;
27668         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27669         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27670         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27671         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27672         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27673         return (int64_t)ret_conv;
27674 }
27675
27676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27677         LDKKeysManager this_arg_conv;
27678         this_arg_conv.inner = (void*)(this_arg & (~1));
27679         this_arg_conv.is_owned = false;
27680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27681         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27682         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
27683         return (int64_t)ret_ret;
27684 }
27685
27686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27687         LDKPhantomKeysManager this_obj_conv;
27688         this_obj_conv.inner = (void*)(this_obj & (~1));
27689         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27691         PhantomKeysManager_free(this_obj_conv);
27692 }
27693
27694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
27695         LDKPhantomKeysManager this_arg_conv;
27696         this_arg_conv.inner = (void*)(this_arg & (~1));
27697         this_arg_conv.is_owned = false;
27698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27699         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
27700         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
27701         return (int64_t)ret_ret;
27702 }
27703
27704 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) {
27705         unsigned char seed_arr[32];
27706         CHECK((*env)->GetArrayLength(env, seed) == 32);
27707         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
27708         unsigned char (*seed_ref)[32] = &seed_arr;
27709         unsigned char cross_node_seed_arr[32];
27710         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
27711         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
27712         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
27713         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
27714         int64_t ret_ref = 0;
27715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27718         ret_ref = (uintptr_t)ret_var.inner;
27719         if (ret_var.is_owned) {
27720                 ret_ref |= 1;
27721         }
27722         return ret_ref;
27723 }
27724
27725 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) {
27726         LDKPhantomKeysManager this_arg_conv;
27727         this_arg_conv.inner = (void*)(this_arg & (~1));
27728         this_arg_conv.is_owned = false;
27729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27730         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
27731         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
27732         if (descriptors_constr.datalen > 0)
27733                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
27734         else
27735                 descriptors_constr.data = NULL;
27736         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
27737         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
27738                 int64_t descriptors_conv_27 = descriptors_vals[b];
27739                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
27740                 CHECK_ACCESS(descriptors_conv_27_ptr);
27741                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
27742                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
27743                 descriptors_constr.data[b] = descriptors_conv_27_conv;
27744         }
27745         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
27746         LDKCVec_TxOutZ outputs_constr;
27747         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
27748         if (outputs_constr.datalen > 0)
27749                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
27750         else
27751                 outputs_constr.data = NULL;
27752         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
27753         for (size_t h = 0; h < outputs_constr.datalen; h++) {
27754                 int64_t outputs_conv_7 = outputs_vals[h];
27755                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
27756                 CHECK_ACCESS(outputs_conv_7_ptr);
27757                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
27758                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
27759                 outputs_constr.data[h] = outputs_conv_7_conv;
27760         }
27761         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
27762         LDKCVec_u8Z change_destination_script_ref;
27763         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
27764         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
27765         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
27766         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
27767         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
27768         return (int64_t)ret_conv;
27769 }
27770
27771 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) {
27772         LDKPhantomKeysManager this_arg_conv;
27773         this_arg_conv.inner = (void*)(this_arg & (~1));
27774         this_arg_conv.is_owned = false;
27775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27776         unsigned char params_arr[32];
27777         CHECK((*env)->GetArrayLength(env, params) == 32);
27778         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
27779         unsigned char (*params_ref)[32] = &params_arr;
27780         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
27781         int64_t ret_ref = 0;
27782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27785         ret_ref = (uintptr_t)ret_var.inner;
27786         if (ret_var.is_owned) {
27787                 ret_ref |= 1;
27788         }
27789         return ret_ref;
27790 }
27791
27792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27793         LDKChannelManager this_obj_conv;
27794         this_obj_conv.inner = (void*)(this_obj & (~1));
27795         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27797         ChannelManager_free(this_obj_conv);
27798 }
27799
27800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27801         LDKChainParameters this_obj_conv;
27802         this_obj_conv.inner = (void*)(this_obj & (~1));
27803         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27805         ChainParameters_free(this_obj_conv);
27806 }
27807
27808 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
27809         LDKChainParameters this_ptr_conv;
27810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27811         this_ptr_conv.is_owned = false;
27812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27813         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
27814         return ret_conv;
27815 }
27816
27817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27818         LDKChainParameters this_ptr_conv;
27819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27820         this_ptr_conv.is_owned = false;
27821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27822         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
27823         ChainParameters_set_network(&this_ptr_conv, val_conv);
27824 }
27825
27826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
27827         LDKChainParameters this_ptr_conv;
27828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27829         this_ptr_conv.is_owned = false;
27830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27831         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
27832         int64_t ret_ref = 0;
27833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27836         ret_ref = (uintptr_t)ret_var.inner;
27837         if (ret_var.is_owned) {
27838                 ret_ref |= 1;
27839         }
27840         return ret_ref;
27841 }
27842
27843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27844         LDKChainParameters this_ptr_conv;
27845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27846         this_ptr_conv.is_owned = false;
27847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27848         LDKBestBlock val_conv;
27849         val_conv.inner = (void*)(val & (~1));
27850         val_conv.is_owned = (val & 1) || (val == 0);
27851         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27852         val_conv = BestBlock_clone(&val_conv);
27853         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
27854 }
27855
27856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
27857         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
27858         LDKBestBlock best_block_arg_conv;
27859         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
27860         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
27861         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
27862         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
27863         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
27864         int64_t ret_ref = 0;
27865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27868         ret_ref = (uintptr_t)ret_var.inner;
27869         if (ret_var.is_owned) {
27870                 ret_ref |= 1;
27871         }
27872         return ret_ref;
27873 }
27874
27875 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
27876         LDKChainParameters ret_var = ChainParameters_clone(arg);
27877 int64_t ret_ref = 0;
27878 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27879 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27880 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27881 ret_ref = (uintptr_t)ret_var.inner;
27882 if (ret_var.is_owned) {
27883         ret_ref |= 1;
27884 }
27885         return ret_ref;
27886 }
27887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27888         LDKChainParameters arg_conv;
27889         arg_conv.inner = (void*)(arg & (~1));
27890         arg_conv.is_owned = false;
27891         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27892         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
27893         return ret_conv;
27894 }
27895
27896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27897         LDKChainParameters orig_conv;
27898         orig_conv.inner = (void*)(orig & (~1));
27899         orig_conv.is_owned = false;
27900         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27901         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
27902         int64_t ret_ref = 0;
27903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27906         ret_ref = (uintptr_t)ret_var.inner;
27907         if (ret_var.is_owned) {
27908                 ret_ref |= 1;
27909         }
27910         return ret_ref;
27911 }
27912
27913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27914         LDKCounterpartyForwardingInfo this_obj_conv;
27915         this_obj_conv.inner = (void*)(this_obj & (~1));
27916         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27918         CounterpartyForwardingInfo_free(this_obj_conv);
27919 }
27920
27921 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27922         LDKCounterpartyForwardingInfo this_ptr_conv;
27923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27924         this_ptr_conv.is_owned = false;
27925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27926         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
27927         return ret_conv;
27928 }
27929
27930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27931         LDKCounterpartyForwardingInfo this_ptr_conv;
27932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27933         this_ptr_conv.is_owned = false;
27934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27935         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
27936 }
27937
27938 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27939         LDKCounterpartyForwardingInfo this_ptr_conv;
27940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27941         this_ptr_conv.is_owned = false;
27942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27943         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
27944         return ret_conv;
27945 }
27946
27947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27948         LDKCounterpartyForwardingInfo this_ptr_conv;
27949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27950         this_ptr_conv.is_owned = false;
27951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27952         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
27953 }
27954
27955 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
27956         LDKCounterpartyForwardingInfo this_ptr_conv;
27957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27958         this_ptr_conv.is_owned = false;
27959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27960         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
27961         return ret_conv;
27962 }
27963
27964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27965         LDKCounterpartyForwardingInfo this_ptr_conv;
27966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27967         this_ptr_conv.is_owned = false;
27968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27969         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
27970 }
27971
27972 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) {
27973         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
27974         int64_t ret_ref = 0;
27975         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27976         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27978         ret_ref = (uintptr_t)ret_var.inner;
27979         if (ret_var.is_owned) {
27980                 ret_ref |= 1;
27981         }
27982         return ret_ref;
27983 }
27984
27985 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
27986         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
27987 int64_t ret_ref = 0;
27988 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27989 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27990 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27991 ret_ref = (uintptr_t)ret_var.inner;
27992 if (ret_var.is_owned) {
27993         ret_ref |= 1;
27994 }
27995         return ret_ref;
27996 }
27997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27998         LDKCounterpartyForwardingInfo arg_conv;
27999         arg_conv.inner = (void*)(arg & (~1));
28000         arg_conv.is_owned = false;
28001         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28002         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
28003         return ret_conv;
28004 }
28005
28006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28007         LDKCounterpartyForwardingInfo orig_conv;
28008         orig_conv.inner = (void*)(orig & (~1));
28009         orig_conv.is_owned = false;
28010         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28011         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
28012         int64_t ret_ref = 0;
28013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28016         ret_ref = (uintptr_t)ret_var.inner;
28017         if (ret_var.is_owned) {
28018                 ret_ref |= 1;
28019         }
28020         return ret_ref;
28021 }
28022
28023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28024         LDKChannelCounterparty this_obj_conv;
28025         this_obj_conv.inner = (void*)(this_obj & (~1));
28026         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28028         ChannelCounterparty_free(this_obj_conv);
28029 }
28030
28031 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28032         LDKChannelCounterparty this_ptr_conv;
28033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28034         this_ptr_conv.is_owned = false;
28035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28036         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28037         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
28038         return ret_arr;
28039 }
28040
28041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28042         LDKChannelCounterparty this_ptr_conv;
28043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28044         this_ptr_conv.is_owned = false;
28045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28046         LDKPublicKey val_ref;
28047         CHECK((*env)->GetArrayLength(env, val) == 33);
28048         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28049         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
28050 }
28051
28052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28053         LDKChannelCounterparty this_ptr_conv;
28054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28055         this_ptr_conv.is_owned = false;
28056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28057         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
28058         int64_t ret_ref = 0;
28059         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28060         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28062         ret_ref = (uintptr_t)ret_var.inner;
28063         if (ret_var.is_owned) {
28064                 ret_ref |= 1;
28065         }
28066         return ret_ref;
28067 }
28068
28069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28070         LDKChannelCounterparty this_ptr_conv;
28071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28072         this_ptr_conv.is_owned = false;
28073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28074         LDKInitFeatures val_conv;
28075         val_conv.inner = (void*)(val & (~1));
28076         val_conv.is_owned = (val & 1) || (val == 0);
28077         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28078         val_conv = InitFeatures_clone(&val_conv);
28079         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
28080 }
28081
28082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
28083         LDKChannelCounterparty this_ptr_conv;
28084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28085         this_ptr_conv.is_owned = false;
28086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28087         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
28088         return ret_conv;
28089 }
28090
28091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28092         LDKChannelCounterparty this_ptr_conv;
28093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28094         this_ptr_conv.is_owned = false;
28095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28096         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
28097 }
28098
28099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
28100         LDKChannelCounterparty this_ptr_conv;
28101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28102         this_ptr_conv.is_owned = false;
28103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28104         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
28105         int64_t ret_ref = 0;
28106         if ((uintptr_t)ret_var.inner > 4096) {
28107                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28108                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28110                 ret_ref = (uintptr_t)ret_var.inner;
28111                 if (ret_var.is_owned) {
28112                         ret_ref |= 1;
28113                 }
28114         }
28115         return ret_ref;
28116 }
28117
28118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28119         LDKChannelCounterparty this_ptr_conv;
28120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28121         this_ptr_conv.is_owned = false;
28122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28123         LDKCounterpartyForwardingInfo val_conv;
28124         val_conv.inner = (void*)(val & (~1));
28125         val_conv.is_owned = (val & 1) || (val == 0);
28126         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28127         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
28128         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
28129 }
28130
28131 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) {
28132         LDKPublicKey node_id_arg_ref;
28133         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
28134         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
28135         LDKInitFeatures features_arg_conv;
28136         features_arg_conv.inner = (void*)(features_arg & (~1));
28137         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
28138         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
28139         features_arg_conv = InitFeatures_clone(&features_arg_conv);
28140         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
28141         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
28142         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
28143         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
28144         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
28145         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
28146         int64_t ret_ref = 0;
28147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28150         ret_ref = (uintptr_t)ret_var.inner;
28151         if (ret_var.is_owned) {
28152                 ret_ref |= 1;
28153         }
28154         return ret_ref;
28155 }
28156
28157 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
28158         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
28159 int64_t ret_ref = 0;
28160 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28161 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28162 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28163 ret_ref = (uintptr_t)ret_var.inner;
28164 if (ret_var.is_owned) {
28165         ret_ref |= 1;
28166 }
28167         return ret_ref;
28168 }
28169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28170         LDKChannelCounterparty arg_conv;
28171         arg_conv.inner = (void*)(arg & (~1));
28172         arg_conv.is_owned = false;
28173         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28174         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
28175         return ret_conv;
28176 }
28177
28178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28179         LDKChannelCounterparty orig_conv;
28180         orig_conv.inner = (void*)(orig & (~1));
28181         orig_conv.is_owned = false;
28182         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28183         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
28184         int64_t ret_ref = 0;
28185         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28186         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28188         ret_ref = (uintptr_t)ret_var.inner;
28189         if (ret_var.is_owned) {
28190                 ret_ref |= 1;
28191         }
28192         return ret_ref;
28193 }
28194
28195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28196         LDKChannelDetails this_obj_conv;
28197         this_obj_conv.inner = (void*)(this_obj & (~1));
28198         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28200         ChannelDetails_free(this_obj_conv);
28201 }
28202
28203 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28204         LDKChannelDetails this_ptr_conv;
28205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28206         this_ptr_conv.is_owned = false;
28207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28208         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28209         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
28210         return ret_arr;
28211 }
28212
28213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28214         LDKChannelDetails this_ptr_conv;
28215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28216         this_ptr_conv.is_owned = false;
28217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28218         LDKThirtyTwoBytes val_ref;
28219         CHECK((*env)->GetArrayLength(env, val) == 32);
28220         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28221         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
28222 }
28223
28224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
28225         LDKChannelDetails this_ptr_conv;
28226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28227         this_ptr_conv.is_owned = false;
28228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28229         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
28230         int64_t ret_ref = 0;
28231         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28232         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28234         ret_ref = (uintptr_t)ret_var.inner;
28235         if (ret_var.is_owned) {
28236                 ret_ref |= 1;
28237         }
28238         return ret_ref;
28239 }
28240
28241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28242         LDKChannelDetails this_ptr_conv;
28243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28244         this_ptr_conv.is_owned = false;
28245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28246         LDKChannelCounterparty val_conv;
28247         val_conv.inner = (void*)(val & (~1));
28248         val_conv.is_owned = (val & 1) || (val == 0);
28249         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28250         val_conv = ChannelCounterparty_clone(&val_conv);
28251         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
28252 }
28253
28254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
28255         LDKChannelDetails this_ptr_conv;
28256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28257         this_ptr_conv.is_owned = false;
28258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28259         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
28260         int64_t ret_ref = 0;
28261         if ((uintptr_t)ret_var.inner > 4096) {
28262                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28263                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28265                 ret_ref = (uintptr_t)ret_var.inner;
28266                 if (ret_var.is_owned) {
28267                         ret_ref |= 1;
28268                 }
28269         }
28270         return ret_ref;
28271 }
28272
28273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28274         LDKChannelDetails this_ptr_conv;
28275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28276         this_ptr_conv.is_owned = false;
28277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28278         LDKOutPoint val_conv;
28279         val_conv.inner = (void*)(val & (~1));
28280         val_conv.is_owned = (val & 1) || (val == 0);
28281         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28282         val_conv = OutPoint_clone(&val_conv);
28283         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
28284 }
28285
28286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
28287         LDKChannelDetails this_ptr_conv;
28288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28289         this_ptr_conv.is_owned = false;
28290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28291         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
28292         int64_t ret_ref = 0;
28293         if ((uintptr_t)ret_var.inner > 4096) {
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         }
28302         return ret_ref;
28303 }
28304
28305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28306         LDKChannelDetails this_ptr_conv;
28307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28308         this_ptr_conv.is_owned = false;
28309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28310         LDKChannelTypeFeatures val_conv;
28311         val_conv.inner = (void*)(val & (~1));
28312         val_conv.is_owned = (val & 1) || (val == 0);
28313         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28314         val_conv = ChannelTypeFeatures_clone(&val_conv);
28315         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
28316 }
28317
28318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28319         LDKChannelDetails this_ptr_conv;
28320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28321         this_ptr_conv.is_owned = false;
28322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28323         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28324         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
28325         int64_t ret_ref = (uintptr_t)ret_copy;
28326         return ret_ref;
28327 }
28328
28329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28330         LDKChannelDetails this_ptr_conv;
28331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28332         this_ptr_conv.is_owned = false;
28333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28334         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28335         CHECK_ACCESS(val_ptr);
28336         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28337         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28338         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
28339 }
28340
28341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
28342         LDKChannelDetails this_ptr_conv;
28343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28344         this_ptr_conv.is_owned = false;
28345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28346         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28347         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
28348         int64_t ret_ref = (uintptr_t)ret_copy;
28349         return ret_ref;
28350 }
28351
28352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28353         LDKChannelDetails this_ptr_conv;
28354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28355         this_ptr_conv.is_owned = false;
28356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28357         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28358         CHECK_ACCESS(val_ptr);
28359         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28360         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28361         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
28362 }
28363
28364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28365         LDKChannelDetails this_ptr_conv;
28366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28367         this_ptr_conv.is_owned = false;
28368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28369         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
28370         return ret_conv;
28371 }
28372
28373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28374         LDKChannelDetails this_ptr_conv;
28375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28376         this_ptr_conv.is_owned = false;
28377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28378         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
28379 }
28380
28381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
28382         LDKChannelDetails this_ptr_conv;
28383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28384         this_ptr_conv.is_owned = false;
28385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28386         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28387         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
28388         int64_t ret_ref = (uintptr_t)ret_copy;
28389         return ret_ref;
28390 }
28391
28392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28393         LDKChannelDetails this_ptr_conv;
28394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28395         this_ptr_conv.is_owned = false;
28396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28397         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28398         CHECK_ACCESS(val_ptr);
28399         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28400         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28401         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
28402 }
28403
28404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28405         LDKChannelDetails this_ptr_conv;
28406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28407         this_ptr_conv.is_owned = false;
28408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28409         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
28410         return ret_conv;
28411 }
28412
28413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28414         LDKChannelDetails this_ptr_conv;
28415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28416         this_ptr_conv.is_owned = false;
28417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28418         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
28419 }
28420
28421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28422         LDKChannelDetails this_ptr_conv;
28423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28424         this_ptr_conv.is_owned = false;
28425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28426         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
28427         return ret_conv;
28428 }
28429
28430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28431         LDKChannelDetails this_ptr_conv;
28432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28433         this_ptr_conv.is_owned = false;
28434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28435         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
28436 }
28437
28438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28439         LDKChannelDetails this_ptr_conv;
28440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28441         this_ptr_conv.is_owned = false;
28442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28443         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
28444         return ret_conv;
28445 }
28446
28447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28448         LDKChannelDetails this_ptr_conv;
28449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28450         this_ptr_conv.is_owned = false;
28451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28452         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
28453 }
28454
28455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28456         LDKChannelDetails this_ptr_conv;
28457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28458         this_ptr_conv.is_owned = false;
28459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28460         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
28461         return ret_conv;
28462 }
28463
28464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28465         LDKChannelDetails this_ptr_conv;
28466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28467         this_ptr_conv.is_owned = false;
28468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28469         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
28470 }
28471
28472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
28473         LDKChannelDetails this_ptr_conv;
28474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28475         this_ptr_conv.is_owned = false;
28476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28477         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
28478         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
28479         int64_t ret_ref = (uintptr_t)ret_copy;
28480         return ret_ref;
28481 }
28482
28483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28484         LDKChannelDetails this_ptr_conv;
28485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28486         this_ptr_conv.is_owned = false;
28487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28488         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28489         CHECK_ACCESS(val_ptr);
28490         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
28491         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
28492         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
28493 }
28494
28495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28496         LDKChannelDetails this_ptr_conv;
28497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28498         this_ptr_conv.is_owned = false;
28499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28500         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
28501         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
28502         int64_t ret_ref = (uintptr_t)ret_copy;
28503         return ret_ref;
28504 }
28505
28506 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) {
28507         LDKChannelDetails this_ptr_conv;
28508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28509         this_ptr_conv.is_owned = false;
28510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28511         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28512         CHECK_ACCESS(val_ptr);
28513         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
28514         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
28515         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
28516 }
28517
28518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
28519         LDKChannelDetails this_ptr_conv;
28520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28521         this_ptr_conv.is_owned = false;
28522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28523         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
28524         return ret_conv;
28525 }
28526
28527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28528         LDKChannelDetails this_ptr_conv;
28529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28530         this_ptr_conv.is_owned = false;
28531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28532         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
28533 }
28534
28535 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
28536         LDKChannelDetails this_ptr_conv;
28537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28538         this_ptr_conv.is_owned = false;
28539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28540         jboolean ret_conv = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
28541         return ret_conv;
28542 }
28543
28544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28545         LDKChannelDetails this_ptr_conv;
28546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28547         this_ptr_conv.is_owned = false;
28548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28549         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
28550 }
28551
28552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
28553         LDKChannelDetails this_ptr_conv;
28554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28555         this_ptr_conv.is_owned = false;
28556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28557         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
28558         return ret_conv;
28559 }
28560
28561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28562         LDKChannelDetails this_ptr_conv;
28563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28564         this_ptr_conv.is_owned = false;
28565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28566         ChannelDetails_set_is_usable(&this_ptr_conv, val);
28567 }
28568
28569 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
28570         LDKChannelDetails this_ptr_conv;
28571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28572         this_ptr_conv.is_owned = false;
28573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28574         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
28575         return ret_conv;
28576 }
28577
28578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28579         LDKChannelDetails this_ptr_conv;
28580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28581         this_ptr_conv.is_owned = false;
28582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28583         ChannelDetails_set_is_public(&this_ptr_conv, val);
28584 }
28585
28586 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 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 inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
28587         LDKThirtyTwoBytes channel_id_arg_ref;
28588         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28589         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28590         LDKChannelCounterparty counterparty_arg_conv;
28591         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
28592         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
28593         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
28594         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
28595         LDKOutPoint funding_txo_arg_conv;
28596         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
28597         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
28598         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
28599         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
28600         LDKChannelTypeFeatures channel_type_arg_conv;
28601         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
28602         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
28603         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
28604         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
28605         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
28606         CHECK_ACCESS(short_channel_id_arg_ptr);
28607         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
28608         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
28609         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
28610         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
28611         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
28612         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
28613         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
28614         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
28615         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
28616         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
28617         CHECK_ACCESS(confirmations_required_arg_ptr);
28618         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
28619         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
28620         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
28621         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
28622         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
28623         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
28624         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, 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, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
28625         int64_t ret_ref = 0;
28626         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28627         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28629         ret_ref = (uintptr_t)ret_var.inner;
28630         if (ret_var.is_owned) {
28631                 ret_ref |= 1;
28632         }
28633         return ret_ref;
28634 }
28635
28636 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
28637         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
28638 int64_t ret_ref = 0;
28639 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28640 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28641 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28642 ret_ref = (uintptr_t)ret_var.inner;
28643 if (ret_var.is_owned) {
28644         ret_ref |= 1;
28645 }
28646         return ret_ref;
28647 }
28648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28649         LDKChannelDetails arg_conv;
28650         arg_conv.inner = (void*)(arg & (~1));
28651         arg_conv.is_owned = false;
28652         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28653         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
28654         return ret_conv;
28655 }
28656
28657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28658         LDKChannelDetails orig_conv;
28659         orig_conv.inner = (void*)(orig & (~1));
28660         orig_conv.is_owned = false;
28661         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28662         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
28663         int64_t ret_ref = 0;
28664         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28665         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28667         ret_ref = (uintptr_t)ret_var.inner;
28668         if (ret_var.is_owned) {
28669                 ret_ref |= 1;
28670         }
28671         return ret_ref;
28672 }
28673
28674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
28675         LDKChannelDetails this_arg_conv;
28676         this_arg_conv.inner = (void*)(this_arg & (~1));
28677         this_arg_conv.is_owned = false;
28678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28679         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28680         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
28681         int64_t ret_ref = (uintptr_t)ret_copy;
28682         return ret_ref;
28683 }
28684
28685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28686         if ((this_ptr & 1) != 0) return;
28687         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28688         CHECK_ACCESS(this_ptr_ptr);
28689         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
28690         FREE((void*)this_ptr);
28691         PaymentSendFailure_free(this_ptr_conv);
28692 }
28693
28694 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
28695         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28696         *ret_copy = PaymentSendFailure_clone(arg);
28697 int64_t ret_ref = (uintptr_t)ret_copy;
28698         return ret_ref;
28699 }
28700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28701         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
28702         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
28703         return ret_conv;
28704 }
28705
28706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28707         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
28708         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28709         *ret_copy = PaymentSendFailure_clone(orig_conv);
28710         int64_t ret_ref = (uintptr_t)ret_copy;
28711         return ret_ref;
28712 }
28713
28714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
28715         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
28716         CHECK_ACCESS(a_ptr);
28717         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
28718         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
28719         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28720         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
28721         int64_t ret_ref = (uintptr_t)ret_copy;
28722         return ret_ref;
28723 }
28724
28725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
28726         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
28727         a_constr.datalen = (*env)->GetArrayLength(env, a);
28728         if (a_constr.datalen > 0)
28729                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
28730         else
28731                 a_constr.data = NULL;
28732         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
28733         for (size_t w = 0; w < a_constr.datalen; w++) {
28734                 int64_t a_conv_22 = a_vals[w];
28735                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
28736                 CHECK_ACCESS(a_conv_22_ptr);
28737                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
28738                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
28739                 a_constr.data[w] = a_conv_22_conv;
28740         }
28741         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
28742         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28743         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
28744         int64_t ret_ref = (uintptr_t)ret_copy;
28745         return ret_ref;
28746 }
28747
28748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
28749         LDKCVec_APIErrorZ a_constr;
28750         a_constr.datalen = (*env)->GetArrayLength(env, a);
28751         if (a_constr.datalen > 0)
28752                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
28753         else
28754                 a_constr.data = NULL;
28755         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
28756         for (size_t k = 0; k < a_constr.datalen; k++) {
28757                 int64_t a_conv_10 = a_vals[k];
28758                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
28759                 CHECK_ACCESS(a_conv_10_ptr);
28760                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
28761                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
28762                 a_constr.data[k] = a_conv_10_conv;
28763         }
28764         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
28765         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28766         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
28767         int64_t ret_ref = (uintptr_t)ret_copy;
28768         return ret_ref;
28769 }
28770
28771 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) {
28772         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
28773         results_constr.datalen = (*env)->GetArrayLength(env, results);
28774         if (results_constr.datalen > 0)
28775                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
28776         else
28777                 results_constr.data = NULL;
28778         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
28779         for (size_t w = 0; w < results_constr.datalen; w++) {
28780                 int64_t results_conv_22 = results_vals[w];
28781                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
28782                 CHECK_ACCESS(results_conv_22_ptr);
28783                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
28784                 results_constr.data[w] = results_conv_22_conv;
28785         }
28786         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
28787         LDKRouteParameters failed_paths_retry_conv;
28788         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
28789         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
28790         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
28791         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
28792         LDKThirtyTwoBytes payment_id_ref;
28793         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
28794         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
28795         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
28796         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
28797         int64_t ret_ref = (uintptr_t)ret_copy;
28798         return ret_ref;
28799 }
28800
28801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28802         LDKPhantomRouteHints this_obj_conv;
28803         this_obj_conv.inner = (void*)(this_obj & (~1));
28804         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28806         PhantomRouteHints_free(this_obj_conv);
28807 }
28808
28809 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28810         LDKPhantomRouteHints this_ptr_conv;
28811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28812         this_ptr_conv.is_owned = false;
28813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28814         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
28815         int64_tArray ret_arr = NULL;
28816         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28817         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28818         for (size_t q = 0; q < ret_var.datalen; q++) {
28819                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
28820                 int64_t ret_conv_16_ref = 0;
28821                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28822                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28823                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
28824                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
28825                 if (ret_conv_16_var.is_owned) {
28826                         ret_conv_16_ref |= 1;
28827                 }
28828                 ret_arr_ptr[q] = ret_conv_16_ref;
28829         }
28830         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28831         FREE(ret_var.data);
28832         return ret_arr;
28833 }
28834
28835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28836         LDKPhantomRouteHints this_ptr_conv;
28837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28838         this_ptr_conv.is_owned = false;
28839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28840         LDKCVec_ChannelDetailsZ val_constr;
28841         val_constr.datalen = (*env)->GetArrayLength(env, val);
28842         if (val_constr.datalen > 0)
28843                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28844         else
28845                 val_constr.data = NULL;
28846         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28847         for (size_t q = 0; q < val_constr.datalen; q++) {
28848                 int64_t val_conv_16 = val_vals[q];
28849                 LDKChannelDetails val_conv_16_conv;
28850                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
28851                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
28852                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
28853                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
28854                 val_constr.data[q] = val_conv_16_conv;
28855         }
28856         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28857         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
28858 }
28859
28860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
28861         LDKPhantomRouteHints this_ptr_conv;
28862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28863         this_ptr_conv.is_owned = false;
28864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28865         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
28866         return ret_conv;
28867 }
28868
28869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28870         LDKPhantomRouteHints this_ptr_conv;
28871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28872         this_ptr_conv.is_owned = false;
28873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28874         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
28875 }
28876
28877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28878         LDKPhantomRouteHints this_ptr_conv;
28879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28880         this_ptr_conv.is_owned = false;
28881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28882         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28883         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
28884         return ret_arr;
28885 }
28886
28887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28888         LDKPhantomRouteHints this_ptr_conv;
28889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28890         this_ptr_conv.is_owned = false;
28891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28892         LDKPublicKey val_ref;
28893         CHECK((*env)->GetArrayLength(env, val) == 33);
28894         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28895         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
28896 }
28897
28898 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) {
28899         LDKCVec_ChannelDetailsZ channels_arg_constr;
28900         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
28901         if (channels_arg_constr.datalen > 0)
28902                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28903         else
28904                 channels_arg_constr.data = NULL;
28905         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
28906         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
28907                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
28908                 LDKChannelDetails channels_arg_conv_16_conv;
28909                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
28910                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
28911                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
28912                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
28913                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
28914         }
28915         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
28916         LDKPublicKey real_node_pubkey_arg_ref;
28917         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
28918         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
28919         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
28920         int64_t ret_ref = 0;
28921         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28922         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28924         ret_ref = (uintptr_t)ret_var.inner;
28925         if (ret_var.is_owned) {
28926                 ret_ref |= 1;
28927         }
28928         return ret_ref;
28929 }
28930
28931 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
28932         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
28933 int64_t ret_ref = 0;
28934 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28935 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28936 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28937 ret_ref = (uintptr_t)ret_var.inner;
28938 if (ret_var.is_owned) {
28939         ret_ref |= 1;
28940 }
28941         return ret_ref;
28942 }
28943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28944         LDKPhantomRouteHints arg_conv;
28945         arg_conv.inner = (void*)(arg & (~1));
28946         arg_conv.is_owned = false;
28947         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28948         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
28949         return ret_conv;
28950 }
28951
28952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28953         LDKPhantomRouteHints orig_conv;
28954         orig_conv.inner = (void*)(orig & (~1));
28955         orig_conv.is_owned = false;
28956         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28957         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
28958         int64_t ret_ref = 0;
28959         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28960         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28962         ret_ref = (uintptr_t)ret_var.inner;
28963         if (ret_var.is_owned) {
28964                 ret_ref |= 1;
28965         }
28966         return ret_ref;
28967 }
28968
28969 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) {
28970         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
28971         CHECK_ACCESS(fee_est_ptr);
28972         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
28973         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
28974                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28975                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
28976         }
28977         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
28978         CHECK_ACCESS(chain_monitor_ptr);
28979         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
28980         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
28981                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28982                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
28983         }
28984         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
28985         CHECK_ACCESS(tx_broadcaster_ptr);
28986         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
28987         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28988                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28989                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
28990         }
28991         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
28992         CHECK_ACCESS(logger_ptr);
28993         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28994         if (logger_conv.free == LDKLogger_JCalls_free) {
28995                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28996                 LDKLogger_JCalls_cloned(&logger_conv);
28997         }
28998         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
28999         CHECK_ACCESS(keys_manager_ptr);
29000         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
29001         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
29002                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29003                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
29004         }
29005         LDKUserConfig config_conv;
29006         config_conv.inner = (void*)(config & (~1));
29007         config_conv.is_owned = (config & 1) || (config == 0);
29008         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
29009         config_conv = UserConfig_clone(&config_conv);
29010         LDKChainParameters params_conv;
29011         params_conv.inner = (void*)(params & (~1));
29012         params_conv.is_owned = (params & 1) || (params == 0);
29013         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
29014         params_conv = ChainParameters_clone(&params_conv);
29015         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
29016         int64_t ret_ref = 0;
29017         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29018         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29020         ret_ref = (uintptr_t)ret_var.inner;
29021         if (ret_var.is_owned) {
29022                 ret_ref |= 1;
29023         }
29024         return ret_ref;
29025 }
29026
29027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
29028         LDKChannelManager this_arg_conv;
29029         this_arg_conv.inner = (void*)(this_arg & (~1));
29030         this_arg_conv.is_owned = false;
29031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29032         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
29033         int64_t ret_ref = 0;
29034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29037         ret_ref = (uintptr_t)ret_var.inner;
29038         if (ret_var.is_owned) {
29039                 ret_ref |= 1;
29040         }
29041         return ret_ref;
29042 }
29043
29044 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) {
29045         LDKChannelManager this_arg_conv;
29046         this_arg_conv.inner = (void*)(this_arg & (~1));
29047         this_arg_conv.is_owned = false;
29048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29049         LDKPublicKey their_network_key_ref;
29050         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
29051         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
29052         LDKUserConfig override_config_conv;
29053         override_config_conv.inner = (void*)(override_config & (~1));
29054         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
29055         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
29056         override_config_conv = UserConfig_clone(&override_config_conv);
29057         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
29058         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
29059         return (int64_t)ret_conv;
29060 }
29061
29062 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29063         LDKChannelManager this_arg_conv;
29064         this_arg_conv.inner = (void*)(this_arg & (~1));
29065         this_arg_conv.is_owned = false;
29066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29067         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
29068         int64_tArray ret_arr = NULL;
29069         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29070         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29071         for (size_t q = 0; q < ret_var.datalen; q++) {
29072                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29073                 int64_t ret_conv_16_ref = 0;
29074                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29075                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29076                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29077                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
29078                 if (ret_conv_16_var.is_owned) {
29079                         ret_conv_16_ref |= 1;
29080                 }
29081                 ret_arr_ptr[q] = ret_conv_16_ref;
29082         }
29083         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29084         FREE(ret_var.data);
29085         return ret_arr;
29086 }
29087
29088 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29089         LDKChannelManager this_arg_conv;
29090         this_arg_conv.inner = (void*)(this_arg & (~1));
29091         this_arg_conv.is_owned = false;
29092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29093         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
29094         int64_tArray ret_arr = NULL;
29095         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29096         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29097         for (size_t q = 0; q < ret_var.datalen; q++) {
29098                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
29099                 int64_t ret_conv_16_ref = 0;
29100                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29101                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29102                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
29103                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
29104                 if (ret_conv_16_var.is_owned) {
29105                         ret_conv_16_ref |= 1;
29106                 }
29107                 ret_arr_ptr[q] = ret_conv_16_ref;
29108         }
29109         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29110         FREE(ret_var.data);
29111         return ret_arr;
29112 }
29113
29114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
29115         LDKChannelManager this_arg_conv;
29116         this_arg_conv.inner = (void*)(this_arg & (~1));
29117         this_arg_conv.is_owned = false;
29118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29119         unsigned char channel_id_arr[32];
29120         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29121         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29122         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29123         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29124         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
29125         return (int64_t)ret_conv;
29126 }
29127
29128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
29129         LDKChannelManager this_arg_conv;
29130         this_arg_conv.inner = (void*)(this_arg & (~1));
29131         this_arg_conv.is_owned = false;
29132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29133         unsigned char channel_id_arr[32];
29134         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29135         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29136         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29137         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29138         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
29139         return (int64_t)ret_conv;
29140 }
29141
29142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
29143         LDKChannelManager this_arg_conv;
29144         this_arg_conv.inner = (void*)(this_arg & (~1));
29145         this_arg_conv.is_owned = false;
29146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29147         unsigned char channel_id_arr[32];
29148         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
29149         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
29150         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
29151         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29152         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
29153         return (int64_t)ret_conv;
29154 }
29155
29156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
29157         LDKChannelManager this_arg_conv;
29158         this_arg_conv.inner = (void*)(this_arg & (~1));
29159         this_arg_conv.is_owned = false;
29160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29161         ChannelManager_force_close_all_channels(&this_arg_conv);
29162 }
29163
29164 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) {
29165         LDKChannelManager this_arg_conv;
29166         this_arg_conv.inner = (void*)(this_arg & (~1));
29167         this_arg_conv.is_owned = false;
29168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29169         LDKRoute route_conv;
29170         route_conv.inner = (void*)(route & (~1));
29171         route_conv.is_owned = false;
29172         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29173         LDKThirtyTwoBytes payment_hash_ref;
29174         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29175         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29176         LDKThirtyTwoBytes payment_secret_ref;
29177         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
29178         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
29179         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
29180         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
29181         return (int64_t)ret_conv;
29182 }
29183
29184 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) {
29185         LDKChannelManager this_arg_conv;
29186         this_arg_conv.inner = (void*)(this_arg & (~1));
29187         this_arg_conv.is_owned = false;
29188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29189         LDKRoute route_conv;
29190         route_conv.inner = (void*)(route & (~1));
29191         route_conv.is_owned = false;
29192         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29193         LDKThirtyTwoBytes payment_id_ref;
29194         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29195         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29196         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
29197         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
29198         return (int64_t)ret_conv;
29199 }
29200
29201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
29202         LDKChannelManager this_arg_conv;
29203         this_arg_conv.inner = (void*)(this_arg & (~1));
29204         this_arg_conv.is_owned = false;
29205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29206         LDKThirtyTwoBytes payment_id_ref;
29207         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
29208         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
29209         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
29210 }
29211
29212 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) {
29213         LDKChannelManager this_arg_conv;
29214         this_arg_conv.inner = (void*)(this_arg & (~1));
29215         this_arg_conv.is_owned = false;
29216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29217         LDKRoute route_conv;
29218         route_conv.inner = (void*)(route & (~1));
29219         route_conv.is_owned = false;
29220         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
29221         LDKThirtyTwoBytes payment_preimage_ref;
29222         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
29223         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
29224         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
29225         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
29226         return (int64_t)ret_conv;
29227 }
29228
29229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
29230         LDKChannelManager this_arg_conv;
29231         this_arg_conv.inner = (void*)(this_arg & (~1));
29232         this_arg_conv.is_owned = false;
29233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29234         unsigned char temporary_channel_id_arr[32];
29235         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
29236         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
29237         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
29238         LDKTransaction funding_transaction_ref;
29239         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
29240         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
29241         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
29242         funding_transaction_ref.data_is_owned = true;
29243         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29244         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
29245         return (int64_t)ret_conv;
29246 }
29247
29248 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) {
29249         LDKChannelManager this_arg_conv;
29250         this_arg_conv.inner = (void*)(this_arg & (~1));
29251         this_arg_conv.is_owned = false;
29252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29253         LDKThreeBytes rgb_ref;
29254         CHECK((*env)->GetArrayLength(env, rgb) == 3);
29255         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
29256         LDKThirtyTwoBytes alias_ref;
29257         CHECK((*env)->GetArrayLength(env, alias) == 32);
29258         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
29259         LDKCVec_NetAddressZ addresses_constr;
29260         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
29261         if (addresses_constr.datalen > 0)
29262                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
29263         else
29264                 addresses_constr.data = NULL;
29265         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
29266         for (size_t m = 0; m < addresses_constr.datalen; m++) {
29267                 int64_t addresses_conv_12 = addresses_vals[m];
29268                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
29269                 CHECK_ACCESS(addresses_conv_12_ptr);
29270                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
29271                 addresses_constr.data[m] = addresses_conv_12_conv;
29272         }
29273         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
29274         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
29275 }
29276
29277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
29278         LDKChannelManager this_arg_conv;
29279         this_arg_conv.inner = (void*)(this_arg & (~1));
29280         this_arg_conv.is_owned = false;
29281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29282         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
29283 }
29284
29285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
29286         LDKChannelManager this_arg_conv;
29287         this_arg_conv.inner = (void*)(this_arg & (~1));
29288         this_arg_conv.is_owned = false;
29289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29290         ChannelManager_timer_tick_occurred(&this_arg_conv);
29291 }
29292
29293 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
29294         LDKChannelManager this_arg_conv;
29295         this_arg_conv.inner = (void*)(this_arg & (~1));
29296         this_arg_conv.is_owned = false;
29297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29298         unsigned char payment_hash_arr[32];
29299         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29300         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
29301         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
29302         jboolean ret_conv = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
29303         return ret_conv;
29304 }
29305
29306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
29307         LDKChannelManager this_arg_conv;
29308         this_arg_conv.inner = (void*)(this_arg & (~1));
29309         this_arg_conv.is_owned = false;
29310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29311         LDKThirtyTwoBytes payment_preimage_ref;
29312         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
29313         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
29314         jboolean ret_conv = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
29315         return ret_conv;
29316 }
29317
29318 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29319         LDKChannelManager this_arg_conv;
29320         this_arg_conv.inner = (void*)(this_arg & (~1));
29321         this_arg_conv.is_owned = false;
29322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29323         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29324         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
29325         return ret_arr;
29326 }
29327
29328 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, int64_t user_channel_id) {
29329         LDKChannelManager this_arg_conv;
29330         this_arg_conv.inner = (void*)(this_arg & (~1));
29331         this_arg_conv.is_owned = false;
29332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29333         unsigned char temporary_channel_id_arr[32];
29334         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
29335         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
29336         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
29337         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29338         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, user_channel_id);
29339         return (int64_t)ret_conv;
29340 }
29341
29342 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) {
29343         LDKChannelManager this_arg_conv;
29344         this_arg_conv.inner = (void*)(this_arg & (~1));
29345         this_arg_conv.is_owned = false;
29346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29347         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29348         CHECK_ACCESS(min_value_msat_ptr);
29349         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29350         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29351         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
29352         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
29353         return (int64_t)ret_conv;
29354 }
29355
29356 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) {
29357         LDKChannelManager this_arg_conv;
29358         this_arg_conv.inner = (void*)(this_arg & (~1));
29359         this_arg_conv.is_owned = false;
29360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29361         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29362         CHECK_ACCESS(min_value_msat_ptr);
29363         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29364         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29365         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
29366         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
29367         return (int64_t)ret_conv;
29368 }
29369
29370 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) {
29371         LDKChannelManager this_arg_conv;
29372         this_arg_conv.inner = (void*)(this_arg & (~1));
29373         this_arg_conv.is_owned = false;
29374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29375         LDKThirtyTwoBytes payment_hash_ref;
29376         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29377         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29378         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29379         CHECK_ACCESS(min_value_msat_ptr);
29380         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29381         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29382         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
29383         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
29384         return (int64_t)ret_conv;
29385 }
29386
29387 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) {
29388         LDKChannelManager this_arg_conv;
29389         this_arg_conv.inner = (void*)(this_arg & (~1));
29390         this_arg_conv.is_owned = false;
29391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29392         LDKThirtyTwoBytes payment_hash_ref;
29393         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29394         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29395         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
29396         CHECK_ACCESS(min_value_msat_ptr);
29397         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
29398         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
29399         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
29400         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
29401         return (int64_t)ret_conv;
29402 }
29403
29404 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) {
29405         LDKChannelManager this_arg_conv;
29406         this_arg_conv.inner = (void*)(this_arg & (~1));
29407         this_arg_conv.is_owned = false;
29408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29409         LDKThirtyTwoBytes payment_hash_ref;
29410         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
29411         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
29412         LDKThirtyTwoBytes payment_secret_ref;
29413         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
29414         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
29415         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
29416         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
29417         return (int64_t)ret_conv;
29418 }
29419
29420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
29421         LDKChannelManager this_arg_conv;
29422         this_arg_conv.inner = (void*)(this_arg & (~1));
29423         this_arg_conv.is_owned = false;
29424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29425         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
29426         return ret_conv;
29427 }
29428
29429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
29430         LDKChannelManager this_arg_conv;
29431         this_arg_conv.inner = (void*)(this_arg & (~1));
29432         this_arg_conv.is_owned = false;
29433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29434         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
29435         int64_t ret_ref = 0;
29436         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29437         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29439         ret_ref = (uintptr_t)ret_var.inner;
29440         if (ret_var.is_owned) {
29441                 ret_ref |= 1;
29442         }
29443         return ret_ref;
29444 }
29445
29446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29447         LDKChannelManager this_arg_conv;
29448         this_arg_conv.inner = (void*)(this_arg & (~1));
29449         this_arg_conv.is_owned = false;
29450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29451         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
29452         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
29453         return (int64_t)ret_ret;
29454 }
29455
29456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29457         LDKChannelManager this_arg_conv;
29458         this_arg_conv.inner = (void*)(this_arg & (~1));
29459         this_arg_conv.is_owned = false;
29460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29461         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
29462         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
29463         return (int64_t)ret_ret;
29464 }
29465
29466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
29467         LDKChannelManager this_arg_conv;
29468         this_arg_conv.inner = (void*)(this_arg & (~1));
29469         this_arg_conv.is_owned = false;
29470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29471         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
29472         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
29473         return (int64_t)ret_ret;
29474 }
29475
29476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
29477         LDKChannelManager this_arg_conv;
29478         this_arg_conv.inner = (void*)(this_arg & (~1));
29479         this_arg_conv.is_owned = false;
29480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29481         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
29482         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
29483         return (int64_t)ret_ret;
29484 }
29485
29486 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) {
29487         LDKChannelManager this_arg_conv;
29488         this_arg_conv.inner = (void*)(this_arg & (~1));
29489         this_arg_conv.is_owned = false;
29490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29491         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
29492         return ret_conv;
29493 }
29494
29495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
29496         LDKChannelManager this_arg_conv;
29497         this_arg_conv.inner = (void*)(this_arg & (~1));
29498         this_arg_conv.is_owned = false;
29499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29500         ChannelManager_await_persistable_update(&this_arg_conv);
29501 }
29502
29503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
29504         LDKChannelManager this_arg_conv;
29505         this_arg_conv.inner = (void*)(this_arg & (~1));
29506         this_arg_conv.is_owned = false;
29507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29508         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
29509         int64_t ret_ref = 0;
29510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29513         ret_ref = (uintptr_t)ret_var.inner;
29514         if (ret_var.is_owned) {
29515                 ret_ref |= 1;
29516         }
29517         return ret_ref;
29518 }
29519
29520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
29521         LDKChannelManager this_arg_conv;
29522         this_arg_conv.inner = (void*)(this_arg & (~1));
29523         this_arg_conv.is_owned = false;
29524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29525         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
29526         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
29527         return (int64_t)ret_ret;
29528 }
29529
29530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
29531         LDKCounterpartyForwardingInfo obj_conv;
29532         obj_conv.inner = (void*)(obj & (~1));
29533         obj_conv.is_owned = false;
29534         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29535         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
29536         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29537         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29538         CVec_u8Z_free(ret_var);
29539         return ret_arr;
29540 }
29541
29542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29543         LDKu8slice ser_ref;
29544         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29545         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29546         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
29547         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
29548         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29549         return (int64_t)ret_conv;
29550 }
29551
29552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
29553         LDKChannelCounterparty obj_conv;
29554         obj_conv.inner = (void*)(obj & (~1));
29555         obj_conv.is_owned = false;
29556         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29557         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
29558         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29559         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29560         CVec_u8Z_free(ret_var);
29561         return ret_arr;
29562 }
29563
29564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29565         LDKu8slice ser_ref;
29566         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29567         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29568         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
29569         *ret_conv = ChannelCounterparty_read(ser_ref);
29570         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29571         return (int64_t)ret_conv;
29572 }
29573
29574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
29575         LDKChannelDetails obj_conv;
29576         obj_conv.inner = (void*)(obj & (~1));
29577         obj_conv.is_owned = false;
29578         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29579         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
29580         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29581         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29582         CVec_u8Z_free(ret_var);
29583         return ret_arr;
29584 }
29585
29586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29587         LDKu8slice ser_ref;
29588         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29589         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29590         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
29591         *ret_conv = ChannelDetails_read(ser_ref);
29592         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29593         return (int64_t)ret_conv;
29594 }
29595
29596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
29597         LDKPhantomRouteHints obj_conv;
29598         obj_conv.inner = (void*)(obj & (~1));
29599         obj_conv.is_owned = false;
29600         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29601         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
29602         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29603         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29604         CVec_u8Z_free(ret_var);
29605         return ret_arr;
29606 }
29607
29608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29609         LDKu8slice ser_ref;
29610         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29611         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29612         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
29613         *ret_conv = PhantomRouteHints_read(ser_ref);
29614         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29615         return (int64_t)ret_conv;
29616 }
29617
29618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
29619         LDKChannelManager obj_conv;
29620         obj_conv.inner = (void*)(obj & (~1));
29621         obj_conv.is_owned = false;
29622         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29623         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
29624         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29625         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29626         CVec_u8Z_free(ret_var);
29627         return ret_arr;
29628 }
29629
29630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29631         LDKChannelManagerReadArgs this_obj_conv;
29632         this_obj_conv.inner = (void*)(this_obj & (~1));
29633         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29635         ChannelManagerReadArgs_free(this_obj_conv);
29636 }
29637
29638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
29639         LDKChannelManagerReadArgs this_ptr_conv;
29640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29641         this_ptr_conv.is_owned = false;
29642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29643         // WARNING: This object doesn't live past this scope, needs clone!
29644         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
29645         return ret_ret;
29646 }
29647
29648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29649         LDKChannelManagerReadArgs this_ptr_conv;
29650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29651         this_ptr_conv.is_owned = false;
29652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29653         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29654         CHECK_ACCESS(val_ptr);
29655         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
29656         if (val_conv.free == LDKKeysInterface_JCalls_free) {
29657                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29658                 LDKKeysInterface_JCalls_cloned(&val_conv);
29659         }
29660         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
29661 }
29662
29663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
29664         LDKChannelManagerReadArgs this_ptr_conv;
29665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29666         this_ptr_conv.is_owned = false;
29667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29668         // WARNING: This object doesn't live past this scope, needs clone!
29669         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
29670         return ret_ret;
29671 }
29672
29673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29674         LDKChannelManagerReadArgs this_ptr_conv;
29675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29676         this_ptr_conv.is_owned = false;
29677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29678         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29679         CHECK_ACCESS(val_ptr);
29680         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
29681         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
29682                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29683                 LDKFeeEstimator_JCalls_cloned(&val_conv);
29684         }
29685         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
29686 }
29687
29688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
29689         LDKChannelManagerReadArgs this_ptr_conv;
29690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29691         this_ptr_conv.is_owned = false;
29692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29693         // WARNING: This object doesn't live past this scope, needs clone!
29694         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
29695         return ret_ret;
29696 }
29697
29698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29699         LDKChannelManagerReadArgs this_ptr_conv;
29700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29701         this_ptr_conv.is_owned = false;
29702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29703         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29704         CHECK_ACCESS(val_ptr);
29705         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
29706         if (val_conv.free == LDKWatch_JCalls_free) {
29707                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29708                 LDKWatch_JCalls_cloned(&val_conv);
29709         }
29710         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
29711 }
29712
29713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
29714         LDKChannelManagerReadArgs this_ptr_conv;
29715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29716         this_ptr_conv.is_owned = false;
29717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29718         // WARNING: This object doesn't live past this scope, needs clone!
29719         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
29720         return ret_ret;
29721 }
29722
29723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29724         LDKChannelManagerReadArgs this_ptr_conv;
29725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29726         this_ptr_conv.is_owned = false;
29727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29728         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29729         CHECK_ACCESS(val_ptr);
29730         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
29731         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
29732                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29733                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
29734         }
29735         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
29736 }
29737
29738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
29739         LDKChannelManagerReadArgs this_ptr_conv;
29740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29741         this_ptr_conv.is_owned = false;
29742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29743         // WARNING: This object doesn't live past this scope, needs clone!
29744         int64_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
29745         return ret_ret;
29746 }
29747
29748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29749         LDKChannelManagerReadArgs this_ptr_conv;
29750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29751         this_ptr_conv.is_owned = false;
29752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29753         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29754         CHECK_ACCESS(val_ptr);
29755         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
29756         if (val_conv.free == LDKLogger_JCalls_free) {
29757                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29758                 LDKLogger_JCalls_cloned(&val_conv);
29759         }
29760         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
29761 }
29762
29763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
29764         LDKChannelManagerReadArgs this_ptr_conv;
29765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29766         this_ptr_conv.is_owned = false;
29767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29768         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
29769         int64_t ret_ref = 0;
29770         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29771         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29773         ret_ref = (uintptr_t)ret_var.inner;
29774         if (ret_var.is_owned) {
29775                 ret_ref |= 1;
29776         }
29777         return ret_ref;
29778 }
29779
29780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29781         LDKChannelManagerReadArgs this_ptr_conv;
29782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29783         this_ptr_conv.is_owned = false;
29784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29785         LDKUserConfig val_conv;
29786         val_conv.inner = (void*)(val & (~1));
29787         val_conv.is_owned = (val & 1) || (val == 0);
29788         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29789         val_conv = UserConfig_clone(&val_conv);
29790         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
29791 }
29792
29793 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) {
29794         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
29795         CHECK_ACCESS(keys_manager_ptr);
29796         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
29797         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
29798                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29799                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
29800         }
29801         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
29802         CHECK_ACCESS(fee_estimator_ptr);
29803         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29804         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29805                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29806                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29807         }
29808         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
29809         CHECK_ACCESS(chain_monitor_ptr);
29810         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
29811         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
29812                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29813                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
29814         }
29815         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
29816         CHECK_ACCESS(tx_broadcaster_ptr);
29817         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
29818         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29819                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29820                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
29821         }
29822         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
29823         CHECK_ACCESS(logger_ptr);
29824         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29825         if (logger_conv.free == LDKLogger_JCalls_free) {
29826                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29827                 LDKLogger_JCalls_cloned(&logger_conv);
29828         }
29829         LDKUserConfig default_config_conv;
29830         default_config_conv.inner = (void*)(default_config & (~1));
29831         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
29832         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
29833         default_config_conv = UserConfig_clone(&default_config_conv);
29834         LDKCVec_ChannelMonitorZ channel_monitors_constr;
29835         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
29836         if (channel_monitors_constr.datalen > 0)
29837                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
29838         else
29839                 channel_monitors_constr.data = NULL;
29840         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
29841         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
29842                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
29843                 LDKChannelMonitor channel_monitors_conv_16_conv;
29844                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
29845                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
29846                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
29847                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
29848         }
29849         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
29850         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);
29851         int64_t ret_ref = 0;
29852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29855         ret_ref = (uintptr_t)ret_var.inner;
29856         if (ret_var.is_owned) {
29857                 ret_ref |= 1;
29858         }
29859         return ret_ref;
29860 }
29861
29862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
29863         LDKu8slice ser_ref;
29864         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29865         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29866         LDKChannelManagerReadArgs arg_conv;
29867         arg_conv.inner = (void*)(arg & (~1));
29868         arg_conv.is_owned = (arg & 1) || (arg == 0);
29869         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29870         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
29871         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
29872         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
29873         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29874         return (int64_t)ret_conv;
29875 }
29876
29877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29878         LDKDecodeError this_obj_conv;
29879         this_obj_conv.inner = (void*)(this_obj & (~1));
29880         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29882         DecodeError_free(this_obj_conv);
29883 }
29884
29885 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
29886         LDKDecodeError ret_var = DecodeError_clone(arg);
29887 int64_t ret_ref = 0;
29888 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29889 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29890 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29891 ret_ref = (uintptr_t)ret_var.inner;
29892 if (ret_var.is_owned) {
29893         ret_ref |= 1;
29894 }
29895         return ret_ref;
29896 }
29897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29898         LDKDecodeError arg_conv;
29899         arg_conv.inner = (void*)(arg & (~1));
29900         arg_conv.is_owned = false;
29901         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29902         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
29903         return ret_conv;
29904 }
29905
29906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29907         LDKDecodeError orig_conv;
29908         orig_conv.inner = (void*)(orig & (~1));
29909         orig_conv.is_owned = false;
29910         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29911         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
29912         int64_t ret_ref = 0;
29913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29916         ret_ref = (uintptr_t)ret_var.inner;
29917         if (ret_var.is_owned) {
29918                 ret_ref |= 1;
29919         }
29920         return ret_ref;
29921 }
29922
29923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29924         LDKInit this_obj_conv;
29925         this_obj_conv.inner = (void*)(this_obj & (~1));
29926         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29928         Init_free(this_obj_conv);
29929 }
29930
29931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
29932         LDKInit this_ptr_conv;
29933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29934         this_ptr_conv.is_owned = false;
29935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29936         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
29937         int64_t ret_ref = 0;
29938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29941         ret_ref = (uintptr_t)ret_var.inner;
29942         if (ret_var.is_owned) {
29943                 ret_ref |= 1;
29944         }
29945         return ret_ref;
29946 }
29947
29948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29949         LDKInit this_ptr_conv;
29950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29951         this_ptr_conv.is_owned = false;
29952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29953         LDKInitFeatures val_conv;
29954         val_conv.inner = (void*)(val & (~1));
29955         val_conv.is_owned = (val & 1) || (val == 0);
29956         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29957         val_conv = InitFeatures_clone(&val_conv);
29958         Init_set_features(&this_ptr_conv, val_conv);
29959 }
29960
29961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
29962         LDKInit this_ptr_conv;
29963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29964         this_ptr_conv.is_owned = false;
29965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29966         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
29967         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
29968         int64_t ret_ref = (uintptr_t)ret_copy;
29969         return ret_ref;
29970 }
29971
29972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29973         LDKInit this_ptr_conv;
29974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29975         this_ptr_conv.is_owned = false;
29976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29977         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29978         CHECK_ACCESS(val_ptr);
29979         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
29980         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
29981         Init_set_remote_network_address(&this_ptr_conv, val_conv);
29982 }
29983
29984 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) {
29985         LDKInitFeatures features_arg_conv;
29986         features_arg_conv.inner = (void*)(features_arg & (~1));
29987         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
29988         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
29989         features_arg_conv = InitFeatures_clone(&features_arg_conv);
29990         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
29991         CHECK_ACCESS(remote_network_address_arg_ptr);
29992         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
29993         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
29994         int64_t ret_ref = 0;
29995         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29996         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29998         ret_ref = (uintptr_t)ret_var.inner;
29999         if (ret_var.is_owned) {
30000                 ret_ref |= 1;
30001         }
30002         return ret_ref;
30003 }
30004
30005 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
30006         LDKInit ret_var = Init_clone(arg);
30007 int64_t ret_ref = 0;
30008 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30009 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30010 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30011 ret_ref = (uintptr_t)ret_var.inner;
30012 if (ret_var.is_owned) {
30013         ret_ref |= 1;
30014 }
30015         return ret_ref;
30016 }
30017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30018         LDKInit arg_conv;
30019         arg_conv.inner = (void*)(arg & (~1));
30020         arg_conv.is_owned = false;
30021         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30022         int64_t ret_conv = Init_clone_ptr(&arg_conv);
30023         return ret_conv;
30024 }
30025
30026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30027         LDKInit orig_conv;
30028         orig_conv.inner = (void*)(orig & (~1));
30029         orig_conv.is_owned = false;
30030         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30031         LDKInit ret_var = Init_clone(&orig_conv);
30032         int64_t ret_ref = 0;
30033         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30034         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30036         ret_ref = (uintptr_t)ret_var.inner;
30037         if (ret_var.is_owned) {
30038                 ret_ref |= 1;
30039         }
30040         return ret_ref;
30041 }
30042
30043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30044         LDKErrorMessage this_obj_conv;
30045         this_obj_conv.inner = (void*)(this_obj & (~1));
30046         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30048         ErrorMessage_free(this_obj_conv);
30049 }
30050
30051 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30052         LDKErrorMessage this_ptr_conv;
30053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30054         this_ptr_conv.is_owned = false;
30055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30056         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30057         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
30058         return ret_arr;
30059 }
30060
30061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30062         LDKErrorMessage this_ptr_conv;
30063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30064         this_ptr_conv.is_owned = false;
30065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30066         LDKThirtyTwoBytes val_ref;
30067         CHECK((*env)->GetArrayLength(env, val) == 32);
30068         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30069         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
30070 }
30071
30072 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
30073         LDKErrorMessage this_ptr_conv;
30074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30075         this_ptr_conv.is_owned = false;
30076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30077         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
30078         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30079         Str_free(ret_str);
30080         return ret_conv;
30081 }
30082
30083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30084         LDKErrorMessage this_ptr_conv;
30085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30086         this_ptr_conv.is_owned = false;
30087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30088         LDKStr val_conv = java_to_owned_str(env, val);
30089         ErrorMessage_set_data(&this_ptr_conv, val_conv);
30090 }
30091
30092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
30093         LDKThirtyTwoBytes channel_id_arg_ref;
30094         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30095         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30096         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
30097         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
30098         int64_t ret_ref = 0;
30099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30102         ret_ref = (uintptr_t)ret_var.inner;
30103         if (ret_var.is_owned) {
30104                 ret_ref |= 1;
30105         }
30106         return ret_ref;
30107 }
30108
30109 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
30110         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
30111 int64_t ret_ref = 0;
30112 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30113 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30114 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30115 ret_ref = (uintptr_t)ret_var.inner;
30116 if (ret_var.is_owned) {
30117         ret_ref |= 1;
30118 }
30119         return ret_ref;
30120 }
30121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30122         LDKErrorMessage arg_conv;
30123         arg_conv.inner = (void*)(arg & (~1));
30124         arg_conv.is_owned = false;
30125         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30126         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
30127         return ret_conv;
30128 }
30129
30130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30131         LDKErrorMessage orig_conv;
30132         orig_conv.inner = (void*)(orig & (~1));
30133         orig_conv.is_owned = false;
30134         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30135         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
30136         int64_t ret_ref = 0;
30137         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30138         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30140         ret_ref = (uintptr_t)ret_var.inner;
30141         if (ret_var.is_owned) {
30142                 ret_ref |= 1;
30143         }
30144         return ret_ref;
30145 }
30146
30147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30148         LDKWarningMessage this_obj_conv;
30149         this_obj_conv.inner = (void*)(this_obj & (~1));
30150         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30152         WarningMessage_free(this_obj_conv);
30153 }
30154
30155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30156         LDKWarningMessage this_ptr_conv;
30157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30158         this_ptr_conv.is_owned = false;
30159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30160         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30161         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
30162         return ret_arr;
30163 }
30164
30165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30166         LDKWarningMessage this_ptr_conv;
30167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30168         this_ptr_conv.is_owned = false;
30169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30170         LDKThirtyTwoBytes val_ref;
30171         CHECK((*env)->GetArrayLength(env, val) == 32);
30172         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30173         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
30174 }
30175
30176 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
30177         LDKWarningMessage this_ptr_conv;
30178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30179         this_ptr_conv.is_owned = false;
30180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30181         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
30182         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30183         Str_free(ret_str);
30184         return ret_conv;
30185 }
30186
30187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30188         LDKWarningMessage this_ptr_conv;
30189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30190         this_ptr_conv.is_owned = false;
30191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30192         LDKStr val_conv = java_to_owned_str(env, val);
30193         WarningMessage_set_data(&this_ptr_conv, val_conv);
30194 }
30195
30196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
30197         LDKThirtyTwoBytes channel_id_arg_ref;
30198         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
30199         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
30200         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
30201         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
30202         int64_t ret_ref = 0;
30203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30206         ret_ref = (uintptr_t)ret_var.inner;
30207         if (ret_var.is_owned) {
30208                 ret_ref |= 1;
30209         }
30210         return ret_ref;
30211 }
30212
30213 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
30214         LDKWarningMessage ret_var = WarningMessage_clone(arg);
30215 int64_t ret_ref = 0;
30216 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30217 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30218 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30219 ret_ref = (uintptr_t)ret_var.inner;
30220 if (ret_var.is_owned) {
30221         ret_ref |= 1;
30222 }
30223         return ret_ref;
30224 }
30225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30226         LDKWarningMessage arg_conv;
30227         arg_conv.inner = (void*)(arg & (~1));
30228         arg_conv.is_owned = false;
30229         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30230         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
30231         return ret_conv;
30232 }
30233
30234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30235         LDKWarningMessage orig_conv;
30236         orig_conv.inner = (void*)(orig & (~1));
30237         orig_conv.is_owned = false;
30238         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30239         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
30240         int64_t ret_ref = 0;
30241         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30242         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30244         ret_ref = (uintptr_t)ret_var.inner;
30245         if (ret_var.is_owned) {
30246                 ret_ref |= 1;
30247         }
30248         return ret_ref;
30249 }
30250
30251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30252         LDKPing this_obj_conv;
30253         this_obj_conv.inner = (void*)(this_obj & (~1));
30254         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30256         Ping_free(this_obj_conv);
30257 }
30258
30259 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30260         LDKPing this_ptr_conv;
30261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30262         this_ptr_conv.is_owned = false;
30263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30264         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
30265         return ret_conv;
30266 }
30267
30268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30269         LDKPing this_ptr_conv;
30270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30271         this_ptr_conv.is_owned = false;
30272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30273         Ping_set_ponglen(&this_ptr_conv, val);
30274 }
30275
30276 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30277         LDKPing this_ptr_conv;
30278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30279         this_ptr_conv.is_owned = false;
30280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30281         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
30282         return ret_conv;
30283 }
30284
30285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30286         LDKPing this_ptr_conv;
30287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30288         this_ptr_conv.is_owned = false;
30289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30290         Ping_set_byteslen(&this_ptr_conv, val);
30291 }
30292
30293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
30294         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
30295         int64_t ret_ref = 0;
30296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30299         ret_ref = (uintptr_t)ret_var.inner;
30300         if (ret_var.is_owned) {
30301                 ret_ref |= 1;
30302         }
30303         return ret_ref;
30304 }
30305
30306 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
30307         LDKPing ret_var = Ping_clone(arg);
30308 int64_t ret_ref = 0;
30309 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30310 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30311 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30312 ret_ref = (uintptr_t)ret_var.inner;
30313 if (ret_var.is_owned) {
30314         ret_ref |= 1;
30315 }
30316         return ret_ref;
30317 }
30318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30319         LDKPing arg_conv;
30320         arg_conv.inner = (void*)(arg & (~1));
30321         arg_conv.is_owned = false;
30322         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30323         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
30324         return ret_conv;
30325 }
30326
30327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30328         LDKPing orig_conv;
30329         orig_conv.inner = (void*)(orig & (~1));
30330         orig_conv.is_owned = false;
30331         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30332         LDKPing ret_var = Ping_clone(&orig_conv);
30333         int64_t ret_ref = 0;
30334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30337         ret_ref = (uintptr_t)ret_var.inner;
30338         if (ret_var.is_owned) {
30339                 ret_ref |= 1;
30340         }
30341         return ret_ref;
30342 }
30343
30344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30345         LDKPong this_obj_conv;
30346         this_obj_conv.inner = (void*)(this_obj & (~1));
30347         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30349         Pong_free(this_obj_conv);
30350 }
30351
30352 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
30353         LDKPong this_ptr_conv;
30354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30355         this_ptr_conv.is_owned = false;
30356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30357         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
30358         return ret_conv;
30359 }
30360
30361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30362         LDKPong this_ptr_conv;
30363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30364         this_ptr_conv.is_owned = false;
30365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30366         Pong_set_byteslen(&this_ptr_conv, val);
30367 }
30368
30369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
30370         LDKPong ret_var = Pong_new(byteslen_arg);
30371         int64_t ret_ref = 0;
30372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30375         ret_ref = (uintptr_t)ret_var.inner;
30376         if (ret_var.is_owned) {
30377                 ret_ref |= 1;
30378         }
30379         return ret_ref;
30380 }
30381
30382 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
30383         LDKPong ret_var = Pong_clone(arg);
30384 int64_t ret_ref = 0;
30385 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30386 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30387 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30388 ret_ref = (uintptr_t)ret_var.inner;
30389 if (ret_var.is_owned) {
30390         ret_ref |= 1;
30391 }
30392         return ret_ref;
30393 }
30394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30395         LDKPong arg_conv;
30396         arg_conv.inner = (void*)(arg & (~1));
30397         arg_conv.is_owned = false;
30398         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30399         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
30400         return ret_conv;
30401 }
30402
30403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30404         LDKPong orig_conv;
30405         orig_conv.inner = (void*)(orig & (~1));
30406         orig_conv.is_owned = false;
30407         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30408         LDKPong ret_var = Pong_clone(&orig_conv);
30409         int64_t ret_ref = 0;
30410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30413         ret_ref = (uintptr_t)ret_var.inner;
30414         if (ret_var.is_owned) {
30415                 ret_ref |= 1;
30416         }
30417         return ret_ref;
30418 }
30419
30420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30421         LDKOpenChannel this_obj_conv;
30422         this_obj_conv.inner = (void*)(this_obj & (~1));
30423         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30425         OpenChannel_free(this_obj_conv);
30426 }
30427
30428 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
30429         LDKOpenChannel this_ptr_conv;
30430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30431         this_ptr_conv.is_owned = false;
30432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30433         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30434         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
30435         return ret_arr;
30436 }
30437
30438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30439         LDKOpenChannel this_ptr_conv;
30440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30441         this_ptr_conv.is_owned = false;
30442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30443         LDKThirtyTwoBytes val_ref;
30444         CHECK((*env)->GetArrayLength(env, val) == 32);
30445         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30446         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
30447 }
30448
30449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30450         LDKOpenChannel this_ptr_conv;
30451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30452         this_ptr_conv.is_owned = false;
30453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30454         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30455         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
30456         return ret_arr;
30457 }
30458
30459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30460         LDKOpenChannel this_ptr_conv;
30461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30462         this_ptr_conv.is_owned = false;
30463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30464         LDKThirtyTwoBytes val_ref;
30465         CHECK((*env)->GetArrayLength(env, val) == 32);
30466         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30467         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
30468 }
30469
30470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30471         LDKOpenChannel this_ptr_conv;
30472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30473         this_ptr_conv.is_owned = false;
30474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30475         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
30476         return ret_conv;
30477 }
30478
30479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30480         LDKOpenChannel this_ptr_conv;
30481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30482         this_ptr_conv.is_owned = false;
30483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30484         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
30485 }
30486
30487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30488         LDKOpenChannel this_ptr_conv;
30489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30490         this_ptr_conv.is_owned = false;
30491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30492         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
30493         return ret_conv;
30494 }
30495
30496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30497         LDKOpenChannel this_ptr_conv;
30498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30499         this_ptr_conv.is_owned = false;
30500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30501         OpenChannel_set_push_msat(&this_ptr_conv, val);
30502 }
30503
30504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30505         LDKOpenChannel this_ptr_conv;
30506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30507         this_ptr_conv.is_owned = false;
30508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30509         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
30510         return ret_conv;
30511 }
30512
30513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30514         LDKOpenChannel this_ptr_conv;
30515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30516         this_ptr_conv.is_owned = false;
30517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30518         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
30519 }
30520
30521 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) {
30522         LDKOpenChannel this_ptr_conv;
30523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30524         this_ptr_conv.is_owned = false;
30525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30526         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
30527         return ret_conv;
30528 }
30529
30530 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) {
30531         LDKOpenChannel this_ptr_conv;
30532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30533         this_ptr_conv.is_owned = false;
30534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30535         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
30536 }
30537
30538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30539         LDKOpenChannel this_ptr_conv;
30540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30541         this_ptr_conv.is_owned = false;
30542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30543         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
30544         return ret_conv;
30545 }
30546
30547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30548         LDKOpenChannel this_ptr_conv;
30549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30550         this_ptr_conv.is_owned = false;
30551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30552         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
30553 }
30554
30555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30556         LDKOpenChannel this_ptr_conv;
30557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30558         this_ptr_conv.is_owned = false;
30559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30560         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
30561         return ret_conv;
30562 }
30563
30564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30565         LDKOpenChannel this_ptr_conv;
30566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30567         this_ptr_conv.is_owned = false;
30568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30569         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
30570 }
30571
30572 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
30573         LDKOpenChannel this_ptr_conv;
30574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30575         this_ptr_conv.is_owned = false;
30576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30577         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
30578         return ret_conv;
30579 }
30580
30581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30582         LDKOpenChannel this_ptr_conv;
30583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30584         this_ptr_conv.is_owned = false;
30585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30586         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
30587 }
30588
30589 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30590         LDKOpenChannel this_ptr_conv;
30591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30592         this_ptr_conv.is_owned = false;
30593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30594         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
30595         return ret_conv;
30596 }
30597
30598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30599         LDKOpenChannel this_ptr_conv;
30600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30601         this_ptr_conv.is_owned = false;
30602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30603         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
30604 }
30605
30606 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30607         LDKOpenChannel this_ptr_conv;
30608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30609         this_ptr_conv.is_owned = false;
30610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30611         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
30612         return ret_conv;
30613 }
30614
30615 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30616         LDKOpenChannel this_ptr_conv;
30617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30618         this_ptr_conv.is_owned = false;
30619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30620         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
30621 }
30622
30623 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30624         LDKOpenChannel this_ptr_conv;
30625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30626         this_ptr_conv.is_owned = false;
30627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30628         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30629         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
30630         return ret_arr;
30631 }
30632
30633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30634         LDKOpenChannel this_ptr_conv;
30635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30636         this_ptr_conv.is_owned = false;
30637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30638         LDKPublicKey val_ref;
30639         CHECK((*env)->GetArrayLength(env, val) == 33);
30640         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30641         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
30642 }
30643
30644 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30645         LDKOpenChannel this_ptr_conv;
30646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30647         this_ptr_conv.is_owned = false;
30648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30649         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30650         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
30651         return ret_arr;
30652 }
30653
30654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30655         LDKOpenChannel this_ptr_conv;
30656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30657         this_ptr_conv.is_owned = false;
30658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30659         LDKPublicKey val_ref;
30660         CHECK((*env)->GetArrayLength(env, val) == 33);
30661         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30662         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
30663 }
30664
30665 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30666         LDKOpenChannel this_ptr_conv;
30667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30668         this_ptr_conv.is_owned = false;
30669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30670         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30671         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
30672         return ret_arr;
30673 }
30674
30675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30676         LDKOpenChannel this_ptr_conv;
30677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30678         this_ptr_conv.is_owned = false;
30679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30680         LDKPublicKey val_ref;
30681         CHECK((*env)->GetArrayLength(env, val) == 33);
30682         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30683         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
30684 }
30685
30686 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30687         LDKOpenChannel this_ptr_conv;
30688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30689         this_ptr_conv.is_owned = false;
30690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30691         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30692         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
30693         return ret_arr;
30694 }
30695
30696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30697         LDKOpenChannel this_ptr_conv;
30698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30699         this_ptr_conv.is_owned = false;
30700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30701         LDKPublicKey val_ref;
30702         CHECK((*env)->GetArrayLength(env, val) == 33);
30703         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30704         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
30705 }
30706
30707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30708         LDKOpenChannel this_ptr_conv;
30709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30710         this_ptr_conv.is_owned = false;
30711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30712         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30713         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
30714         return ret_arr;
30715 }
30716
30717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30718         LDKOpenChannel this_ptr_conv;
30719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30720         this_ptr_conv.is_owned = false;
30721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30722         LDKPublicKey val_ref;
30723         CHECK((*env)->GetArrayLength(env, val) == 33);
30724         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30725         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
30726 }
30727
30728 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30729         LDKOpenChannel this_ptr_conv;
30730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30731         this_ptr_conv.is_owned = false;
30732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30733         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30734         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
30735         return ret_arr;
30736 }
30737
30738 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) {
30739         LDKOpenChannel this_ptr_conv;
30740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30741         this_ptr_conv.is_owned = false;
30742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30743         LDKPublicKey val_ref;
30744         CHECK((*env)->GetArrayLength(env, val) == 33);
30745         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30746         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
30747 }
30748
30749 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
30750         LDKOpenChannel this_ptr_conv;
30751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30752         this_ptr_conv.is_owned = false;
30753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30754         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
30755         return ret_conv;
30756 }
30757
30758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
30759         LDKOpenChannel this_ptr_conv;
30760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30761         this_ptr_conv.is_owned = false;
30762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30763         OpenChannel_set_channel_flags(&this_ptr_conv, val);
30764 }
30765
30766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
30767         LDKOpenChannel this_ptr_conv;
30768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30769         this_ptr_conv.is_owned = false;
30770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30771         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
30772         int64_t ret_ref = 0;
30773         if ((uintptr_t)ret_var.inner > 4096) {
30774                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30775                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30777                 ret_ref = (uintptr_t)ret_var.inner;
30778                 if (ret_var.is_owned) {
30779                         ret_ref |= 1;
30780                 }
30781         }
30782         return ret_ref;
30783 }
30784
30785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30786         LDKOpenChannel this_ptr_conv;
30787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30788         this_ptr_conv.is_owned = false;
30789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30790         LDKChannelTypeFeatures val_conv;
30791         val_conv.inner = (void*)(val & (~1));
30792         val_conv.is_owned = (val & 1) || (val == 0);
30793         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30794         val_conv = ChannelTypeFeatures_clone(&val_conv);
30795         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
30796 }
30797
30798 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
30799         LDKOpenChannel ret_var = OpenChannel_clone(arg);
30800 int64_t ret_ref = 0;
30801 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30802 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30803 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30804 ret_ref = (uintptr_t)ret_var.inner;
30805 if (ret_var.is_owned) {
30806         ret_ref |= 1;
30807 }
30808         return ret_ref;
30809 }
30810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30811         LDKOpenChannel arg_conv;
30812         arg_conv.inner = (void*)(arg & (~1));
30813         arg_conv.is_owned = false;
30814         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30815         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
30816         return ret_conv;
30817 }
30818
30819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30820         LDKOpenChannel orig_conv;
30821         orig_conv.inner = (void*)(orig & (~1));
30822         orig_conv.is_owned = false;
30823         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30824         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
30825         int64_t ret_ref = 0;
30826         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30827         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30829         ret_ref = (uintptr_t)ret_var.inner;
30830         if (ret_var.is_owned) {
30831                 ret_ref |= 1;
30832         }
30833         return ret_ref;
30834 }
30835
30836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30837         LDKAcceptChannel this_obj_conv;
30838         this_obj_conv.inner = (void*)(this_obj & (~1));
30839         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30841         AcceptChannel_free(this_obj_conv);
30842 }
30843
30844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30845         LDKAcceptChannel this_ptr_conv;
30846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30847         this_ptr_conv.is_owned = false;
30848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30849         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30850         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
30851         return ret_arr;
30852 }
30853
30854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30855         LDKAcceptChannel this_ptr_conv;
30856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30857         this_ptr_conv.is_owned = false;
30858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30859         LDKThirtyTwoBytes val_ref;
30860         CHECK((*env)->GetArrayLength(env, val) == 32);
30861         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30862         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
30863 }
30864
30865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30866         LDKAcceptChannel this_ptr_conv;
30867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30868         this_ptr_conv.is_owned = false;
30869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30870         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
30871         return ret_conv;
30872 }
30873
30874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30875         LDKAcceptChannel this_ptr_conv;
30876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30877         this_ptr_conv.is_owned = false;
30878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30879         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
30880 }
30881
30882 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) {
30883         LDKAcceptChannel this_ptr_conv;
30884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30885         this_ptr_conv.is_owned = false;
30886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30887         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
30888         return ret_conv;
30889 }
30890
30891 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) {
30892         LDKAcceptChannel this_ptr_conv;
30893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30894         this_ptr_conv.is_owned = false;
30895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30896         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
30897 }
30898
30899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30900         LDKAcceptChannel this_ptr_conv;
30901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30902         this_ptr_conv.is_owned = false;
30903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30904         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
30905         return ret_conv;
30906 }
30907
30908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30909         LDKAcceptChannel this_ptr_conv;
30910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30911         this_ptr_conv.is_owned = false;
30912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30913         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
30914 }
30915
30916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30917         LDKAcceptChannel this_ptr_conv;
30918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30919         this_ptr_conv.is_owned = false;
30920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30921         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
30922         return ret_conv;
30923 }
30924
30925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30926         LDKAcceptChannel this_ptr_conv;
30927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30928         this_ptr_conv.is_owned = false;
30929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30930         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
30931 }
30932
30933 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
30934         LDKAcceptChannel this_ptr_conv;
30935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30936         this_ptr_conv.is_owned = false;
30937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30938         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
30939         return ret_conv;
30940 }
30941
30942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
30943         LDKAcceptChannel this_ptr_conv;
30944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30945         this_ptr_conv.is_owned = false;
30946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30947         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
30948 }
30949
30950 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30951         LDKAcceptChannel this_ptr_conv;
30952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30953         this_ptr_conv.is_owned = false;
30954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30955         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
30956         return ret_conv;
30957 }
30958
30959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30960         LDKAcceptChannel this_ptr_conv;
30961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30962         this_ptr_conv.is_owned = false;
30963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30964         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
30965 }
30966
30967 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30968         LDKAcceptChannel this_ptr_conv;
30969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30970         this_ptr_conv.is_owned = false;
30971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30972         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
30973         return ret_conv;
30974 }
30975
30976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30977         LDKAcceptChannel this_ptr_conv;
30978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30979         this_ptr_conv.is_owned = false;
30980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30981         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
30982 }
30983
30984 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30985         LDKAcceptChannel this_ptr_conv;
30986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30987         this_ptr_conv.is_owned = false;
30988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30989         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30990         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
30991         return ret_arr;
30992 }
30993
30994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30995         LDKAcceptChannel this_ptr_conv;
30996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30997         this_ptr_conv.is_owned = false;
30998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30999         LDKPublicKey val_ref;
31000         CHECK((*env)->GetArrayLength(env, val) == 33);
31001         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31002         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
31003 }
31004
31005 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31006         LDKAcceptChannel this_ptr_conv;
31007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31008         this_ptr_conv.is_owned = false;
31009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31010         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31011         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
31012         return ret_arr;
31013 }
31014
31015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31016         LDKAcceptChannel this_ptr_conv;
31017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31018         this_ptr_conv.is_owned = false;
31019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31020         LDKPublicKey val_ref;
31021         CHECK((*env)->GetArrayLength(env, val) == 33);
31022         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31023         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
31024 }
31025
31026 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31027         LDKAcceptChannel this_ptr_conv;
31028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31029         this_ptr_conv.is_owned = false;
31030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31031         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31032         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
31033         return ret_arr;
31034 }
31035
31036 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31037         LDKAcceptChannel this_ptr_conv;
31038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31039         this_ptr_conv.is_owned = false;
31040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31041         LDKPublicKey val_ref;
31042         CHECK((*env)->GetArrayLength(env, val) == 33);
31043         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31044         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
31045 }
31046
31047 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31048         LDKAcceptChannel this_ptr_conv;
31049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31050         this_ptr_conv.is_owned = false;
31051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31052         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31053         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
31054         return ret_arr;
31055 }
31056
31057 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31058         LDKAcceptChannel this_ptr_conv;
31059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31060         this_ptr_conv.is_owned = false;
31061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31062         LDKPublicKey val_ref;
31063         CHECK((*env)->GetArrayLength(env, val) == 33);
31064         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31065         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
31066 }
31067
31068 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
31069         LDKAcceptChannel this_ptr_conv;
31070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31071         this_ptr_conv.is_owned = false;
31072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31073         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31074         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
31075         return ret_arr;
31076 }
31077
31078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31079         LDKAcceptChannel this_ptr_conv;
31080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31081         this_ptr_conv.is_owned = false;
31082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31083         LDKPublicKey val_ref;
31084         CHECK((*env)->GetArrayLength(env, val) == 33);
31085         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31086         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
31087 }
31088
31089 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31090         LDKAcceptChannel this_ptr_conv;
31091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31092         this_ptr_conv.is_owned = false;
31093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31094         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31095         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
31096         return ret_arr;
31097 }
31098
31099 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) {
31100         LDKAcceptChannel this_ptr_conv;
31101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31102         this_ptr_conv.is_owned = false;
31103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31104         LDKPublicKey val_ref;
31105         CHECK((*env)->GetArrayLength(env, val) == 33);
31106         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31107         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
31108 }
31109
31110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
31111         LDKAcceptChannel this_ptr_conv;
31112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31113         this_ptr_conv.is_owned = false;
31114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31115         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
31116         int64_t ret_ref = 0;
31117         if ((uintptr_t)ret_var.inner > 4096) {
31118                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31119                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31121                 ret_ref = (uintptr_t)ret_var.inner;
31122                 if (ret_var.is_owned) {
31123                         ret_ref |= 1;
31124                 }
31125         }
31126         return ret_ref;
31127 }
31128
31129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31130         LDKAcceptChannel this_ptr_conv;
31131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31132         this_ptr_conv.is_owned = false;
31133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31134         LDKChannelTypeFeatures val_conv;
31135         val_conv.inner = (void*)(val & (~1));
31136         val_conv.is_owned = (val & 1) || (val == 0);
31137         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31138         val_conv = ChannelTypeFeatures_clone(&val_conv);
31139         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
31140 }
31141
31142 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
31143         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
31144 int64_t ret_ref = 0;
31145 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31146 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31147 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31148 ret_ref = (uintptr_t)ret_var.inner;
31149 if (ret_var.is_owned) {
31150         ret_ref |= 1;
31151 }
31152         return ret_ref;
31153 }
31154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31155         LDKAcceptChannel arg_conv;
31156         arg_conv.inner = (void*)(arg & (~1));
31157         arg_conv.is_owned = false;
31158         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31159         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
31160         return ret_conv;
31161 }
31162
31163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31164         LDKAcceptChannel orig_conv;
31165         orig_conv.inner = (void*)(orig & (~1));
31166         orig_conv.is_owned = false;
31167         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31168         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
31169         int64_t ret_ref = 0;
31170         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31171         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31173         ret_ref = (uintptr_t)ret_var.inner;
31174         if (ret_var.is_owned) {
31175                 ret_ref |= 1;
31176         }
31177         return ret_ref;
31178 }
31179
31180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31181         LDKFundingCreated this_obj_conv;
31182         this_obj_conv.inner = (void*)(this_obj & (~1));
31183         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31185         FundingCreated_free(this_obj_conv);
31186 }
31187
31188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31189         LDKFundingCreated this_ptr_conv;
31190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31191         this_ptr_conv.is_owned = false;
31192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31193         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31194         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
31195         return ret_arr;
31196 }
31197
31198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31199         LDKFundingCreated this_ptr_conv;
31200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31201         this_ptr_conv.is_owned = false;
31202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31203         LDKThirtyTwoBytes val_ref;
31204         CHECK((*env)->GetArrayLength(env, val) == 32);
31205         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31206         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
31207 }
31208
31209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
31210         LDKFundingCreated this_ptr_conv;
31211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31212         this_ptr_conv.is_owned = false;
31213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31214         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31215         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
31216         return ret_arr;
31217 }
31218
31219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31220         LDKFundingCreated this_ptr_conv;
31221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31222         this_ptr_conv.is_owned = false;
31223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31224         LDKThirtyTwoBytes val_ref;
31225         CHECK((*env)->GetArrayLength(env, val) == 32);
31226         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31227         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
31228 }
31229
31230 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
31231         LDKFundingCreated this_ptr_conv;
31232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31233         this_ptr_conv.is_owned = false;
31234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31235         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
31236         return ret_conv;
31237 }
31238
31239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31240         LDKFundingCreated this_ptr_conv;
31241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31242         this_ptr_conv.is_owned = false;
31243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31244         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
31245 }
31246
31247 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31248         LDKFundingCreated this_ptr_conv;
31249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31250         this_ptr_conv.is_owned = false;
31251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31252         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31253         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
31254         return ret_arr;
31255 }
31256
31257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31258         LDKFundingCreated this_ptr_conv;
31259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31260         this_ptr_conv.is_owned = false;
31261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31262         LDKSignature val_ref;
31263         CHECK((*env)->GetArrayLength(env, val) == 64);
31264         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31265         FundingCreated_set_signature(&this_ptr_conv, val_ref);
31266 }
31267
31268 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) {
31269         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
31270         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
31271         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
31272         LDKThirtyTwoBytes funding_txid_arg_ref;
31273         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
31274         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
31275         LDKSignature signature_arg_ref;
31276         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31277         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31278         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
31279         int64_t ret_ref = 0;
31280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31283         ret_ref = (uintptr_t)ret_var.inner;
31284         if (ret_var.is_owned) {
31285                 ret_ref |= 1;
31286         }
31287         return ret_ref;
31288 }
31289
31290 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
31291         LDKFundingCreated ret_var = FundingCreated_clone(arg);
31292 int64_t ret_ref = 0;
31293 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31294 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31295 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31296 ret_ref = (uintptr_t)ret_var.inner;
31297 if (ret_var.is_owned) {
31298         ret_ref |= 1;
31299 }
31300         return ret_ref;
31301 }
31302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31303         LDKFundingCreated arg_conv;
31304         arg_conv.inner = (void*)(arg & (~1));
31305         arg_conv.is_owned = false;
31306         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31307         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
31308         return ret_conv;
31309 }
31310
31311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31312         LDKFundingCreated orig_conv;
31313         orig_conv.inner = (void*)(orig & (~1));
31314         orig_conv.is_owned = false;
31315         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31316         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
31317         int64_t ret_ref = 0;
31318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31321         ret_ref = (uintptr_t)ret_var.inner;
31322         if (ret_var.is_owned) {
31323                 ret_ref |= 1;
31324         }
31325         return ret_ref;
31326 }
31327
31328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31329         LDKFundingSigned this_obj_conv;
31330         this_obj_conv.inner = (void*)(this_obj & (~1));
31331         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31333         FundingSigned_free(this_obj_conv);
31334 }
31335
31336 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31337         LDKFundingSigned this_ptr_conv;
31338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31339         this_ptr_conv.is_owned = false;
31340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31341         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31342         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
31343         return ret_arr;
31344 }
31345
31346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31347         LDKFundingSigned this_ptr_conv;
31348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31349         this_ptr_conv.is_owned = false;
31350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31351         LDKThirtyTwoBytes val_ref;
31352         CHECK((*env)->GetArrayLength(env, val) == 32);
31353         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31354         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
31355 }
31356
31357 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31358         LDKFundingSigned this_ptr_conv;
31359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31360         this_ptr_conv.is_owned = false;
31361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31362         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31363         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
31364         return ret_arr;
31365 }
31366
31367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31368         LDKFundingSigned this_ptr_conv;
31369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31370         this_ptr_conv.is_owned = false;
31371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31372         LDKSignature val_ref;
31373         CHECK((*env)->GetArrayLength(env, val) == 64);
31374         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31375         FundingSigned_set_signature(&this_ptr_conv, val_ref);
31376 }
31377
31378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
31379         LDKThirtyTwoBytes channel_id_arg_ref;
31380         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31381         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31382         LDKSignature signature_arg_ref;
31383         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31384         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31385         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
31386         int64_t ret_ref = 0;
31387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31390         ret_ref = (uintptr_t)ret_var.inner;
31391         if (ret_var.is_owned) {
31392                 ret_ref |= 1;
31393         }
31394         return ret_ref;
31395 }
31396
31397 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
31398         LDKFundingSigned ret_var = FundingSigned_clone(arg);
31399 int64_t ret_ref = 0;
31400 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31401 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31402 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31403 ret_ref = (uintptr_t)ret_var.inner;
31404 if (ret_var.is_owned) {
31405         ret_ref |= 1;
31406 }
31407         return ret_ref;
31408 }
31409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31410         LDKFundingSigned arg_conv;
31411         arg_conv.inner = (void*)(arg & (~1));
31412         arg_conv.is_owned = false;
31413         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31414         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
31415         return ret_conv;
31416 }
31417
31418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31419         LDKFundingSigned orig_conv;
31420         orig_conv.inner = (void*)(orig & (~1));
31421         orig_conv.is_owned = false;
31422         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31423         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
31424         int64_t ret_ref = 0;
31425         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31426         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31428         ret_ref = (uintptr_t)ret_var.inner;
31429         if (ret_var.is_owned) {
31430                 ret_ref |= 1;
31431         }
31432         return ret_ref;
31433 }
31434
31435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31436         LDKFundingLocked this_obj_conv;
31437         this_obj_conv.inner = (void*)(this_obj & (~1));
31438         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31440         FundingLocked_free(this_obj_conv);
31441 }
31442
31443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31444         LDKFundingLocked this_ptr_conv;
31445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31446         this_ptr_conv.is_owned = false;
31447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31448         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31449         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
31450         return ret_arr;
31451 }
31452
31453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31454         LDKFundingLocked this_ptr_conv;
31455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31456         this_ptr_conv.is_owned = false;
31457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31458         LDKThirtyTwoBytes val_ref;
31459         CHECK((*env)->GetArrayLength(env, val) == 32);
31460         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31461         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
31462 }
31463
31464 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31465         LDKFundingLocked this_ptr_conv;
31466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31467         this_ptr_conv.is_owned = false;
31468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31469         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31470         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
31471         return ret_arr;
31472 }
31473
31474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31475         LDKFundingLocked this_ptr_conv;
31476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31477         this_ptr_conv.is_owned = false;
31478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31479         LDKPublicKey val_ref;
31480         CHECK((*env)->GetArrayLength(env, val) == 33);
31481         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31482         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
31483 }
31484
31485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
31486         LDKFundingLocked 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         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31491         *ret_copy = FundingLocked_get_short_channel_id_alias(&this_ptr_conv);
31492         int64_t ret_ref = (uintptr_t)ret_copy;
31493         return ret_ref;
31494 }
31495
31496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31497         LDKFundingLocked this_ptr_conv;
31498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31499         this_ptr_conv.is_owned = false;
31500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31501         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31502         CHECK_ACCESS(val_ptr);
31503         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31504         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
31505         FundingLocked_set_short_channel_id_alias(&this_ptr_conv, val_conv);
31506 }
31507
31508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, int64_t short_channel_id_alias_arg) {
31509         LDKThirtyTwoBytes channel_id_arg_ref;
31510         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31511         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31512         LDKPublicKey next_per_commitment_point_arg_ref;
31513         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
31514         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
31515         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
31516         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
31517         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
31518         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
31519         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
31520         int64_t ret_ref = 0;
31521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31524         ret_ref = (uintptr_t)ret_var.inner;
31525         if (ret_var.is_owned) {
31526                 ret_ref |= 1;
31527         }
31528         return ret_ref;
31529 }
31530
31531 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
31532         LDKFundingLocked ret_var = FundingLocked_clone(arg);
31533 int64_t ret_ref = 0;
31534 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31535 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31536 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31537 ret_ref = (uintptr_t)ret_var.inner;
31538 if (ret_var.is_owned) {
31539         ret_ref |= 1;
31540 }
31541         return ret_ref;
31542 }
31543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31544         LDKFundingLocked arg_conv;
31545         arg_conv.inner = (void*)(arg & (~1));
31546         arg_conv.is_owned = false;
31547         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31548         int64_t ret_conv = FundingLocked_clone_ptr(&arg_conv);
31549         return ret_conv;
31550 }
31551
31552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31553         LDKFundingLocked orig_conv;
31554         orig_conv.inner = (void*)(orig & (~1));
31555         orig_conv.is_owned = false;
31556         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31557         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
31558         int64_t ret_ref = 0;
31559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31562         ret_ref = (uintptr_t)ret_var.inner;
31563         if (ret_var.is_owned) {
31564                 ret_ref |= 1;
31565         }
31566         return ret_ref;
31567 }
31568
31569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31570         LDKShutdown this_obj_conv;
31571         this_obj_conv.inner = (void*)(this_obj & (~1));
31572         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31574         Shutdown_free(this_obj_conv);
31575 }
31576
31577 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31578         LDKShutdown this_ptr_conv;
31579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31580         this_ptr_conv.is_owned = false;
31581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31582         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31583         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
31584         return ret_arr;
31585 }
31586
31587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31588         LDKShutdown this_ptr_conv;
31589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31590         this_ptr_conv.is_owned = false;
31591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31592         LDKThirtyTwoBytes val_ref;
31593         CHECK((*env)->GetArrayLength(env, val) == 32);
31594         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31595         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
31596 }
31597
31598 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31599         LDKShutdown this_ptr_conv;
31600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31601         this_ptr_conv.is_owned = false;
31602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31603         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
31604         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31605         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31606         return ret_arr;
31607 }
31608
31609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31610         LDKShutdown this_ptr_conv;
31611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31612         this_ptr_conv.is_owned = false;
31613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31614         LDKCVec_u8Z val_ref;
31615         val_ref.datalen = (*env)->GetArrayLength(env, val);
31616         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
31617         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
31618         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
31619 }
31620
31621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
31622         LDKThirtyTwoBytes channel_id_arg_ref;
31623         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31624         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31625         LDKCVec_u8Z scriptpubkey_arg_ref;
31626         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
31627         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
31628         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
31629         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
31630         int64_t ret_ref = 0;
31631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31634         ret_ref = (uintptr_t)ret_var.inner;
31635         if (ret_var.is_owned) {
31636                 ret_ref |= 1;
31637         }
31638         return ret_ref;
31639 }
31640
31641 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
31642         LDKShutdown ret_var = Shutdown_clone(arg);
31643 int64_t ret_ref = 0;
31644 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31645 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31646 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31647 ret_ref = (uintptr_t)ret_var.inner;
31648 if (ret_var.is_owned) {
31649         ret_ref |= 1;
31650 }
31651         return ret_ref;
31652 }
31653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31654         LDKShutdown arg_conv;
31655         arg_conv.inner = (void*)(arg & (~1));
31656         arg_conv.is_owned = false;
31657         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31658         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
31659         return ret_conv;
31660 }
31661
31662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31663         LDKShutdown orig_conv;
31664         orig_conv.inner = (void*)(orig & (~1));
31665         orig_conv.is_owned = false;
31666         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31667         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
31668         int64_t ret_ref = 0;
31669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31672         ret_ref = (uintptr_t)ret_var.inner;
31673         if (ret_var.is_owned) {
31674                 ret_ref |= 1;
31675         }
31676         return ret_ref;
31677 }
31678
31679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31680         LDKClosingSignedFeeRange this_obj_conv;
31681         this_obj_conv.inner = (void*)(this_obj & (~1));
31682         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31684         ClosingSignedFeeRange_free(this_obj_conv);
31685 }
31686
31687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31688         LDKClosingSignedFeeRange 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 = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
31693         return ret_conv;
31694 }
31695
31696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31697         LDKClosingSignedFeeRange 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         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
31702 }
31703
31704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31705         LDKClosingSignedFeeRange 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 = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
31710         return ret_conv;
31711 }
31712
31713 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31714         LDKClosingSignedFeeRange 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         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
31719 }
31720
31721 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) {
31722         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
31723         int64_t ret_ref = 0;
31724         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31725         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31727         ret_ref = (uintptr_t)ret_var.inner;
31728         if (ret_var.is_owned) {
31729                 ret_ref |= 1;
31730         }
31731         return ret_ref;
31732 }
31733
31734 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
31735         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
31736 int64_t ret_ref = 0;
31737 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31738 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31739 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31740 ret_ref = (uintptr_t)ret_var.inner;
31741 if (ret_var.is_owned) {
31742         ret_ref |= 1;
31743 }
31744         return ret_ref;
31745 }
31746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31747         LDKClosingSignedFeeRange arg_conv;
31748         arg_conv.inner = (void*)(arg & (~1));
31749         arg_conv.is_owned = false;
31750         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31751         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
31752         return ret_conv;
31753 }
31754
31755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31756         LDKClosingSignedFeeRange orig_conv;
31757         orig_conv.inner = (void*)(orig & (~1));
31758         orig_conv.is_owned = false;
31759         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31760         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
31761         int64_t ret_ref = 0;
31762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31765         ret_ref = (uintptr_t)ret_var.inner;
31766         if (ret_var.is_owned) {
31767                 ret_ref |= 1;
31768         }
31769         return ret_ref;
31770 }
31771
31772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31773         LDKClosingSigned this_obj_conv;
31774         this_obj_conv.inner = (void*)(this_obj & (~1));
31775         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31777         ClosingSigned_free(this_obj_conv);
31778 }
31779
31780 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31781         LDKClosingSigned this_ptr_conv;
31782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31783         this_ptr_conv.is_owned = false;
31784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31785         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31786         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
31787         return ret_arr;
31788 }
31789
31790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31791         LDKClosingSigned this_ptr_conv;
31792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31793         this_ptr_conv.is_owned = false;
31794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31795         LDKThirtyTwoBytes val_ref;
31796         CHECK((*env)->GetArrayLength(env, val) == 32);
31797         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31798         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
31799 }
31800
31801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31802         LDKClosingSigned this_ptr_conv;
31803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31804         this_ptr_conv.is_owned = false;
31805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31806         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
31807         return ret_conv;
31808 }
31809
31810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31811         LDKClosingSigned this_ptr_conv;
31812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31813         this_ptr_conv.is_owned = false;
31814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31815         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
31816 }
31817
31818 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
31819         LDKClosingSigned this_ptr_conv;
31820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31821         this_ptr_conv.is_owned = false;
31822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31823         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
31824         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
31825         return ret_arr;
31826 }
31827
31828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31829         LDKClosingSigned this_ptr_conv;
31830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31831         this_ptr_conv.is_owned = false;
31832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31833         LDKSignature val_ref;
31834         CHECK((*env)->GetArrayLength(env, val) == 64);
31835         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
31836         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
31837 }
31838
31839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
31840         LDKClosingSigned this_ptr_conv;
31841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31842         this_ptr_conv.is_owned = false;
31843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31844         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
31845         int64_t ret_ref = 0;
31846         if ((uintptr_t)ret_var.inner > 4096) {
31847                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31848                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31850                 ret_ref = (uintptr_t)ret_var.inner;
31851                 if (ret_var.is_owned) {
31852                         ret_ref |= 1;
31853                 }
31854         }
31855         return ret_ref;
31856 }
31857
31858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31859         LDKClosingSigned this_ptr_conv;
31860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31861         this_ptr_conv.is_owned = false;
31862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31863         LDKClosingSignedFeeRange val_conv;
31864         val_conv.inner = (void*)(val & (~1));
31865         val_conv.is_owned = (val & 1) || (val == 0);
31866         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31867         val_conv = ClosingSignedFeeRange_clone(&val_conv);
31868         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
31869 }
31870
31871 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) {
31872         LDKThirtyTwoBytes channel_id_arg_ref;
31873         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
31874         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
31875         LDKSignature signature_arg_ref;
31876         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
31877         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
31878         LDKClosingSignedFeeRange fee_range_arg_conv;
31879         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
31880         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
31881         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
31882         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
31883         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
31884         int64_t ret_ref = 0;
31885         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31886         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31888         ret_ref = (uintptr_t)ret_var.inner;
31889         if (ret_var.is_owned) {
31890                 ret_ref |= 1;
31891         }
31892         return ret_ref;
31893 }
31894
31895 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
31896         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
31897 int64_t ret_ref = 0;
31898 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31899 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31900 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31901 ret_ref = (uintptr_t)ret_var.inner;
31902 if (ret_var.is_owned) {
31903         ret_ref |= 1;
31904 }
31905         return ret_ref;
31906 }
31907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31908         LDKClosingSigned arg_conv;
31909         arg_conv.inner = (void*)(arg & (~1));
31910         arg_conv.is_owned = false;
31911         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31912         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
31913         return ret_conv;
31914 }
31915
31916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31917         LDKClosingSigned orig_conv;
31918         orig_conv.inner = (void*)(orig & (~1));
31919         orig_conv.is_owned = false;
31920         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31921         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
31922         int64_t ret_ref = 0;
31923         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31924         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31926         ret_ref = (uintptr_t)ret_var.inner;
31927         if (ret_var.is_owned) {
31928                 ret_ref |= 1;
31929         }
31930         return ret_ref;
31931 }
31932
31933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31934         LDKUpdateAddHTLC this_obj_conv;
31935         this_obj_conv.inner = (void*)(this_obj & (~1));
31936         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31938         UpdateAddHTLC_free(this_obj_conv);
31939 }
31940
31941 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31942         LDKUpdateAddHTLC this_ptr_conv;
31943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31944         this_ptr_conv.is_owned = false;
31945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31946         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
31948         return ret_arr;
31949 }
31950
31951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31952         LDKUpdateAddHTLC this_ptr_conv;
31953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31954         this_ptr_conv.is_owned = false;
31955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31956         LDKThirtyTwoBytes val_ref;
31957         CHECK((*env)->GetArrayLength(env, val) == 32);
31958         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31959         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
31960 }
31961
31962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31963         LDKUpdateAddHTLC this_ptr_conv;
31964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31965         this_ptr_conv.is_owned = false;
31966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31967         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
31968         return ret_conv;
31969 }
31970
31971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31972         LDKUpdateAddHTLC this_ptr_conv;
31973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31974         this_ptr_conv.is_owned = false;
31975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31976         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
31977 }
31978
31979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31980         LDKUpdateAddHTLC this_ptr_conv;
31981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31982         this_ptr_conv.is_owned = false;
31983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31984         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
31985         return ret_conv;
31986 }
31987
31988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31989         LDKUpdateAddHTLC this_ptr_conv;
31990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31991         this_ptr_conv.is_owned = false;
31992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31993         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
31994 }
31995
31996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
31997         LDKUpdateAddHTLC this_ptr_conv;
31998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31999         this_ptr_conv.is_owned = false;
32000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32001         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32002         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
32003         return ret_arr;
32004 }
32005
32006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32007         LDKUpdateAddHTLC this_ptr_conv;
32008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32009         this_ptr_conv.is_owned = false;
32010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32011         LDKThirtyTwoBytes val_ref;
32012         CHECK((*env)->GetArrayLength(env, val) == 32);
32013         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32014         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
32015 }
32016
32017 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
32018         LDKUpdateAddHTLC this_ptr_conv;
32019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32020         this_ptr_conv.is_owned = false;
32021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32022         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
32023         return ret_conv;
32024 }
32025
32026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32027         LDKUpdateAddHTLC this_ptr_conv;
32028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32029         this_ptr_conv.is_owned = false;
32030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32031         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
32032 }
32033
32034 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
32035         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
32036 int64_t ret_ref = 0;
32037 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32038 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32039 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32040 ret_ref = (uintptr_t)ret_var.inner;
32041 if (ret_var.is_owned) {
32042         ret_ref |= 1;
32043 }
32044         return ret_ref;
32045 }
32046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32047         LDKUpdateAddHTLC arg_conv;
32048         arg_conv.inner = (void*)(arg & (~1));
32049         arg_conv.is_owned = false;
32050         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32051         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
32052         return ret_conv;
32053 }
32054
32055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32056         LDKUpdateAddHTLC orig_conv;
32057         orig_conv.inner = (void*)(orig & (~1));
32058         orig_conv.is_owned = false;
32059         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32060         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
32061         int64_t ret_ref = 0;
32062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32065         ret_ref = (uintptr_t)ret_var.inner;
32066         if (ret_var.is_owned) {
32067                 ret_ref |= 1;
32068         }
32069         return ret_ref;
32070 }
32071
32072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32073         LDKUpdateFulfillHTLC this_obj_conv;
32074         this_obj_conv.inner = (void*)(this_obj & (~1));
32075         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32077         UpdateFulfillHTLC_free(this_obj_conv);
32078 }
32079
32080 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32081         LDKUpdateFulfillHTLC this_ptr_conv;
32082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32083         this_ptr_conv.is_owned = false;
32084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32085         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32086         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
32087         return ret_arr;
32088 }
32089
32090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32091         LDKUpdateFulfillHTLC this_ptr_conv;
32092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32093         this_ptr_conv.is_owned = false;
32094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32095         LDKThirtyTwoBytes val_ref;
32096         CHECK((*env)->GetArrayLength(env, val) == 32);
32097         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32098         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
32099 }
32100
32101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32102         LDKUpdateFulfillHTLC this_ptr_conv;
32103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32104         this_ptr_conv.is_owned = false;
32105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32106         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
32107         return ret_conv;
32108 }
32109
32110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32111         LDKUpdateFulfillHTLC this_ptr_conv;
32112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32113         this_ptr_conv.is_owned = false;
32114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32115         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
32116 }
32117
32118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
32119         LDKUpdateFulfillHTLC this_ptr_conv;
32120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32121         this_ptr_conv.is_owned = false;
32122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32123         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32124         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
32125         return ret_arr;
32126 }
32127
32128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32129         LDKUpdateFulfillHTLC this_ptr_conv;
32130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32131         this_ptr_conv.is_owned = false;
32132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32133         LDKThirtyTwoBytes val_ref;
32134         CHECK((*env)->GetArrayLength(env, val) == 32);
32135         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32136         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
32137 }
32138
32139 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) {
32140         LDKThirtyTwoBytes channel_id_arg_ref;
32141         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32142         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32143         LDKThirtyTwoBytes payment_preimage_arg_ref;
32144         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
32145         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
32146         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
32147         int64_t ret_ref = 0;
32148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32151         ret_ref = (uintptr_t)ret_var.inner;
32152         if (ret_var.is_owned) {
32153                 ret_ref |= 1;
32154         }
32155         return ret_ref;
32156 }
32157
32158 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
32159         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
32160 int64_t ret_ref = 0;
32161 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32162 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32163 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32164 ret_ref = (uintptr_t)ret_var.inner;
32165 if (ret_var.is_owned) {
32166         ret_ref |= 1;
32167 }
32168         return ret_ref;
32169 }
32170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32171         LDKUpdateFulfillHTLC arg_conv;
32172         arg_conv.inner = (void*)(arg & (~1));
32173         arg_conv.is_owned = false;
32174         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32175         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
32176         return ret_conv;
32177 }
32178
32179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32180         LDKUpdateFulfillHTLC orig_conv;
32181         orig_conv.inner = (void*)(orig & (~1));
32182         orig_conv.is_owned = false;
32183         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32184         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
32185         int64_t ret_ref = 0;
32186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32189         ret_ref = (uintptr_t)ret_var.inner;
32190         if (ret_var.is_owned) {
32191                 ret_ref |= 1;
32192         }
32193         return ret_ref;
32194 }
32195
32196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32197         LDKUpdateFailHTLC this_obj_conv;
32198         this_obj_conv.inner = (void*)(this_obj & (~1));
32199         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32201         UpdateFailHTLC_free(this_obj_conv);
32202 }
32203
32204 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32205         LDKUpdateFailHTLC this_ptr_conv;
32206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32207         this_ptr_conv.is_owned = false;
32208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32209         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32210         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
32211         return ret_arr;
32212 }
32213
32214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32215         LDKUpdateFailHTLC this_ptr_conv;
32216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32217         this_ptr_conv.is_owned = false;
32218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32219         LDKThirtyTwoBytes val_ref;
32220         CHECK((*env)->GetArrayLength(env, val) == 32);
32221         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32222         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
32223 }
32224
32225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32226         LDKUpdateFailHTLC this_ptr_conv;
32227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32228         this_ptr_conv.is_owned = false;
32229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32230         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
32231         return ret_conv;
32232 }
32233
32234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32235         LDKUpdateFailHTLC this_ptr_conv;
32236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32237         this_ptr_conv.is_owned = false;
32238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32239         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
32240 }
32241
32242 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
32243         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
32244 int64_t ret_ref = 0;
32245 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32246 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32247 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32248 ret_ref = (uintptr_t)ret_var.inner;
32249 if (ret_var.is_owned) {
32250         ret_ref |= 1;
32251 }
32252         return ret_ref;
32253 }
32254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32255         LDKUpdateFailHTLC arg_conv;
32256         arg_conv.inner = (void*)(arg & (~1));
32257         arg_conv.is_owned = false;
32258         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32259         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
32260         return ret_conv;
32261 }
32262
32263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32264         LDKUpdateFailHTLC orig_conv;
32265         orig_conv.inner = (void*)(orig & (~1));
32266         orig_conv.is_owned = false;
32267         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32268         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
32269         int64_t ret_ref = 0;
32270         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32271         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32273         ret_ref = (uintptr_t)ret_var.inner;
32274         if (ret_var.is_owned) {
32275                 ret_ref |= 1;
32276         }
32277         return ret_ref;
32278 }
32279
32280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32281         LDKUpdateFailMalformedHTLC this_obj_conv;
32282         this_obj_conv.inner = (void*)(this_obj & (~1));
32283         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32285         UpdateFailMalformedHTLC_free(this_obj_conv);
32286 }
32287
32288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32289         LDKUpdateFailMalformedHTLC this_ptr_conv;
32290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32291         this_ptr_conv.is_owned = false;
32292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32293         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32294         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
32295         return ret_arr;
32296 }
32297
32298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32299         LDKUpdateFailMalformedHTLC this_ptr_conv;
32300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32301         this_ptr_conv.is_owned = false;
32302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32303         LDKThirtyTwoBytes val_ref;
32304         CHECK((*env)->GetArrayLength(env, val) == 32);
32305         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32306         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
32307 }
32308
32309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32310         LDKUpdateFailMalformedHTLC this_ptr_conv;
32311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32312         this_ptr_conv.is_owned = false;
32313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32314         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
32315         return ret_conv;
32316 }
32317
32318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32319         LDKUpdateFailMalformedHTLC this_ptr_conv;
32320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32321         this_ptr_conv.is_owned = false;
32322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32323         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
32324 }
32325
32326 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
32327         LDKUpdateFailMalformedHTLC this_ptr_conv;
32328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32329         this_ptr_conv.is_owned = false;
32330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32331         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
32332         return ret_conv;
32333 }
32334
32335 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32336         LDKUpdateFailMalformedHTLC this_ptr_conv;
32337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32338         this_ptr_conv.is_owned = false;
32339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32340         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
32341 }
32342
32343 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
32344         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
32345 int64_t ret_ref = 0;
32346 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32347 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32348 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32349 ret_ref = (uintptr_t)ret_var.inner;
32350 if (ret_var.is_owned) {
32351         ret_ref |= 1;
32352 }
32353         return ret_ref;
32354 }
32355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32356         LDKUpdateFailMalformedHTLC arg_conv;
32357         arg_conv.inner = (void*)(arg & (~1));
32358         arg_conv.is_owned = false;
32359         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32360         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
32361         return ret_conv;
32362 }
32363
32364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32365         LDKUpdateFailMalformedHTLC orig_conv;
32366         orig_conv.inner = (void*)(orig & (~1));
32367         orig_conv.is_owned = false;
32368         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32369         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
32370         int64_t ret_ref = 0;
32371         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32372         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32374         ret_ref = (uintptr_t)ret_var.inner;
32375         if (ret_var.is_owned) {
32376                 ret_ref |= 1;
32377         }
32378         return ret_ref;
32379 }
32380
32381 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32382         LDKCommitmentSigned this_obj_conv;
32383         this_obj_conv.inner = (void*)(this_obj & (~1));
32384         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32386         CommitmentSigned_free(this_obj_conv);
32387 }
32388
32389 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32390         LDKCommitmentSigned this_ptr_conv;
32391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32392         this_ptr_conv.is_owned = false;
32393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32394         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32395         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
32396         return ret_arr;
32397 }
32398
32399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32400         LDKCommitmentSigned this_ptr_conv;
32401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32402         this_ptr_conv.is_owned = false;
32403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32404         LDKThirtyTwoBytes val_ref;
32405         CHECK((*env)->GetArrayLength(env, val) == 32);
32406         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32407         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
32408 }
32409
32410 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
32411         LDKCommitmentSigned this_ptr_conv;
32412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32413         this_ptr_conv.is_owned = false;
32414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32415         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
32416         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
32417         return ret_arr;
32418 }
32419
32420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32421         LDKCommitmentSigned this_ptr_conv;
32422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32423         this_ptr_conv.is_owned = false;
32424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32425         LDKSignature val_ref;
32426         CHECK((*env)->GetArrayLength(env, val) == 64);
32427         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
32428         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
32429 }
32430
32431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
32432         LDKCommitmentSigned this_ptr_conv;
32433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32434         this_ptr_conv.is_owned = false;
32435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32436         LDKCVec_SignatureZ val_constr;
32437         val_constr.datalen = (*env)->GetArrayLength(env, val);
32438         if (val_constr.datalen > 0)
32439                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
32440         else
32441                 val_constr.data = NULL;
32442         for (size_t i = 0; i < val_constr.datalen; i++) {
32443                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
32444                 LDKSignature val_conv_8_ref;
32445                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
32446                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
32447                 val_constr.data[i] = val_conv_8_ref;
32448         }
32449         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
32450 }
32451
32452 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) {
32453         LDKThirtyTwoBytes channel_id_arg_ref;
32454         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32455         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32456         LDKSignature signature_arg_ref;
32457         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
32458         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
32459         LDKCVec_SignatureZ htlc_signatures_arg_constr;
32460         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
32461         if (htlc_signatures_arg_constr.datalen > 0)
32462                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
32463         else
32464                 htlc_signatures_arg_constr.data = NULL;
32465         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
32466                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
32467                 LDKSignature htlc_signatures_arg_conv_8_ref;
32468                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
32469                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
32470                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
32471         }
32472         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
32473         int64_t ret_ref = 0;
32474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32477         ret_ref = (uintptr_t)ret_var.inner;
32478         if (ret_var.is_owned) {
32479                 ret_ref |= 1;
32480         }
32481         return ret_ref;
32482 }
32483
32484 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
32485         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
32486 int64_t ret_ref = 0;
32487 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32488 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32489 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32490 ret_ref = (uintptr_t)ret_var.inner;
32491 if (ret_var.is_owned) {
32492         ret_ref |= 1;
32493 }
32494         return ret_ref;
32495 }
32496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32497         LDKCommitmentSigned arg_conv;
32498         arg_conv.inner = (void*)(arg & (~1));
32499         arg_conv.is_owned = false;
32500         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32501         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
32502         return ret_conv;
32503 }
32504
32505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32506         LDKCommitmentSigned orig_conv;
32507         orig_conv.inner = (void*)(orig & (~1));
32508         orig_conv.is_owned = false;
32509         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32510         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
32511         int64_t ret_ref = 0;
32512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32515         ret_ref = (uintptr_t)ret_var.inner;
32516         if (ret_var.is_owned) {
32517                 ret_ref |= 1;
32518         }
32519         return ret_ref;
32520 }
32521
32522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32523         LDKRevokeAndACK this_obj_conv;
32524         this_obj_conv.inner = (void*)(this_obj & (~1));
32525         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32527         RevokeAndACK_free(this_obj_conv);
32528 }
32529
32530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32531         LDKRevokeAndACK this_ptr_conv;
32532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32533         this_ptr_conv.is_owned = false;
32534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32535         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32536         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
32537         return ret_arr;
32538 }
32539
32540 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32541         LDKRevokeAndACK this_ptr_conv;
32542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32543         this_ptr_conv.is_owned = false;
32544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32545         LDKThirtyTwoBytes val_ref;
32546         CHECK((*env)->GetArrayLength(env, val) == 32);
32547         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32548         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
32549 }
32550
32551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
32552         LDKRevokeAndACK this_ptr_conv;
32553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32554         this_ptr_conv.is_owned = false;
32555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32556         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32557         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
32558         return ret_arr;
32559 }
32560
32561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32562         LDKRevokeAndACK this_ptr_conv;
32563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32564         this_ptr_conv.is_owned = false;
32565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32566         LDKThirtyTwoBytes val_ref;
32567         CHECK((*env)->GetArrayLength(env, val) == 32);
32568         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32569         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
32570 }
32571
32572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32573         LDKRevokeAndACK this_ptr_conv;
32574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32575         this_ptr_conv.is_owned = false;
32576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32577         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32578         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
32579         return ret_arr;
32580 }
32581
32582 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) {
32583         LDKRevokeAndACK this_ptr_conv;
32584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32585         this_ptr_conv.is_owned = false;
32586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32587         LDKPublicKey val_ref;
32588         CHECK((*env)->GetArrayLength(env, val) == 33);
32589         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32590         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
32591 }
32592
32593 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) {
32594         LDKThirtyTwoBytes channel_id_arg_ref;
32595         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32596         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32597         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
32598         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
32599         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
32600         LDKPublicKey next_per_commitment_point_arg_ref;
32601         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
32602         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
32603         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
32604         int64_t ret_ref = 0;
32605         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32606         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32608         ret_ref = (uintptr_t)ret_var.inner;
32609         if (ret_var.is_owned) {
32610                 ret_ref |= 1;
32611         }
32612         return ret_ref;
32613 }
32614
32615 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
32616         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
32617 int64_t ret_ref = 0;
32618 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32619 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32620 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32621 ret_ref = (uintptr_t)ret_var.inner;
32622 if (ret_var.is_owned) {
32623         ret_ref |= 1;
32624 }
32625         return ret_ref;
32626 }
32627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32628         LDKRevokeAndACK arg_conv;
32629         arg_conv.inner = (void*)(arg & (~1));
32630         arg_conv.is_owned = false;
32631         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32632         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
32633         return ret_conv;
32634 }
32635
32636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32637         LDKRevokeAndACK orig_conv;
32638         orig_conv.inner = (void*)(orig & (~1));
32639         orig_conv.is_owned = false;
32640         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32641         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
32642         int64_t ret_ref = 0;
32643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32646         ret_ref = (uintptr_t)ret_var.inner;
32647         if (ret_var.is_owned) {
32648                 ret_ref |= 1;
32649         }
32650         return ret_ref;
32651 }
32652
32653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32654         LDKUpdateFee this_obj_conv;
32655         this_obj_conv.inner = (void*)(this_obj & (~1));
32656         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32658         UpdateFee_free(this_obj_conv);
32659 }
32660
32661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32662         LDKUpdateFee this_ptr_conv;
32663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32664         this_ptr_conv.is_owned = false;
32665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32666         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32667         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
32668         return ret_arr;
32669 }
32670
32671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32672         LDKUpdateFee this_ptr_conv;
32673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32674         this_ptr_conv.is_owned = false;
32675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32676         LDKThirtyTwoBytes val_ref;
32677         CHECK((*env)->GetArrayLength(env, val) == 32);
32678         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32679         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
32680 }
32681
32682 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
32683         LDKUpdateFee this_ptr_conv;
32684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32685         this_ptr_conv.is_owned = false;
32686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32687         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
32688         return ret_conv;
32689 }
32690
32691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32692         LDKUpdateFee 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         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
32697 }
32698
32699 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) {
32700         LDKThirtyTwoBytes channel_id_arg_ref;
32701         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32702         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32703         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
32704         int64_t ret_ref = 0;
32705         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32706         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32708         ret_ref = (uintptr_t)ret_var.inner;
32709         if (ret_var.is_owned) {
32710                 ret_ref |= 1;
32711         }
32712         return ret_ref;
32713 }
32714
32715 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
32716         LDKUpdateFee ret_var = UpdateFee_clone(arg);
32717 int64_t ret_ref = 0;
32718 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32719 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32720 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32721 ret_ref = (uintptr_t)ret_var.inner;
32722 if (ret_var.is_owned) {
32723         ret_ref |= 1;
32724 }
32725         return ret_ref;
32726 }
32727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32728         LDKUpdateFee arg_conv;
32729         arg_conv.inner = (void*)(arg & (~1));
32730         arg_conv.is_owned = false;
32731         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32732         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
32733         return ret_conv;
32734 }
32735
32736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32737         LDKUpdateFee orig_conv;
32738         orig_conv.inner = (void*)(orig & (~1));
32739         orig_conv.is_owned = false;
32740         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32741         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
32742         int64_t ret_ref = 0;
32743         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32744         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32746         ret_ref = (uintptr_t)ret_var.inner;
32747         if (ret_var.is_owned) {
32748                 ret_ref |= 1;
32749         }
32750         return ret_ref;
32751 }
32752
32753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32754         LDKDataLossProtect this_obj_conv;
32755         this_obj_conv.inner = (void*)(this_obj & (~1));
32756         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32758         DataLossProtect_free(this_obj_conv);
32759 }
32760
32761 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
32762         LDKDataLossProtect this_ptr_conv;
32763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32764         this_ptr_conv.is_owned = false;
32765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32766         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32767         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
32768         return ret_arr;
32769 }
32770
32771 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) {
32772         LDKDataLossProtect this_ptr_conv;
32773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32774         this_ptr_conv.is_owned = false;
32775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32776         LDKThirtyTwoBytes val_ref;
32777         CHECK((*env)->GetArrayLength(env, val) == 32);
32778         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32779         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
32780 }
32781
32782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32783         LDKDataLossProtect this_ptr_conv;
32784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32785         this_ptr_conv.is_owned = false;
32786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32787         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32788         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
32789         return ret_arr;
32790 }
32791
32792 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) {
32793         LDKDataLossProtect this_ptr_conv;
32794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32795         this_ptr_conv.is_owned = false;
32796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32797         LDKPublicKey val_ref;
32798         CHECK((*env)->GetArrayLength(env, val) == 33);
32799         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32800         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
32801 }
32802
32803 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) {
32804         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
32805         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
32806         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
32807         LDKPublicKey my_current_per_commitment_point_arg_ref;
32808         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
32809         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
32810         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
32811         int64_t ret_ref = 0;
32812         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32813         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32815         ret_ref = (uintptr_t)ret_var.inner;
32816         if (ret_var.is_owned) {
32817                 ret_ref |= 1;
32818         }
32819         return ret_ref;
32820 }
32821
32822 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
32823         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
32824 int64_t ret_ref = 0;
32825 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32826 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32827 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32828 ret_ref = (uintptr_t)ret_var.inner;
32829 if (ret_var.is_owned) {
32830         ret_ref |= 1;
32831 }
32832         return ret_ref;
32833 }
32834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32835         LDKDataLossProtect arg_conv;
32836         arg_conv.inner = (void*)(arg & (~1));
32837         arg_conv.is_owned = false;
32838         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32839         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
32840         return ret_conv;
32841 }
32842
32843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32844         LDKDataLossProtect orig_conv;
32845         orig_conv.inner = (void*)(orig & (~1));
32846         orig_conv.is_owned = false;
32847         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32848         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
32849         int64_t ret_ref = 0;
32850         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32851         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32853         ret_ref = (uintptr_t)ret_var.inner;
32854         if (ret_var.is_owned) {
32855                 ret_ref |= 1;
32856         }
32857         return ret_ref;
32858 }
32859
32860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32861         LDKChannelReestablish this_obj_conv;
32862         this_obj_conv.inner = (void*)(this_obj & (~1));
32863         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32865         ChannelReestablish_free(this_obj_conv);
32866 }
32867
32868 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32869         LDKChannelReestablish this_ptr_conv;
32870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32871         this_ptr_conv.is_owned = false;
32872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32873         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32874         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
32875         return ret_arr;
32876 }
32877
32878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32879         LDKChannelReestablish this_ptr_conv;
32880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32881         this_ptr_conv.is_owned = false;
32882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32883         LDKThirtyTwoBytes val_ref;
32884         CHECK((*env)->GetArrayLength(env, val) == 32);
32885         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32886         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
32887 }
32888
32889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
32890         LDKChannelReestablish this_ptr_conv;
32891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32892         this_ptr_conv.is_owned = false;
32893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32894         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
32895         return ret_conv;
32896 }
32897
32898 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) {
32899         LDKChannelReestablish this_ptr_conv;
32900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32901         this_ptr_conv.is_owned = false;
32902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32903         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
32904 }
32905
32906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
32907         LDKChannelReestablish this_ptr_conv;
32908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32909         this_ptr_conv.is_owned = false;
32910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32911         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
32912         return ret_conv;
32913 }
32914
32915 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) {
32916         LDKChannelReestablish this_ptr_conv;
32917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32918         this_ptr_conv.is_owned = false;
32919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32920         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
32921 }
32922
32923 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
32924         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
32925 int64_t ret_ref = 0;
32926 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32927 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32928 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32929 ret_ref = (uintptr_t)ret_var.inner;
32930 if (ret_var.is_owned) {
32931         ret_ref |= 1;
32932 }
32933         return ret_ref;
32934 }
32935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32936         LDKChannelReestablish arg_conv;
32937         arg_conv.inner = (void*)(arg & (~1));
32938         arg_conv.is_owned = false;
32939         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32940         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
32941         return ret_conv;
32942 }
32943
32944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32945         LDKChannelReestablish orig_conv;
32946         orig_conv.inner = (void*)(orig & (~1));
32947         orig_conv.is_owned = false;
32948         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32949         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
32950         int64_t ret_ref = 0;
32951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32954         ret_ref = (uintptr_t)ret_var.inner;
32955         if (ret_var.is_owned) {
32956                 ret_ref |= 1;
32957         }
32958         return ret_ref;
32959 }
32960
32961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32962         LDKAnnouncementSignatures this_obj_conv;
32963         this_obj_conv.inner = (void*)(this_obj & (~1));
32964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32966         AnnouncementSignatures_free(this_obj_conv);
32967 }
32968
32969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32970         LDKAnnouncementSignatures this_ptr_conv;
32971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32972         this_ptr_conv.is_owned = false;
32973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32974         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32975         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
32976         return ret_arr;
32977 }
32978
32979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32980         LDKAnnouncementSignatures this_ptr_conv;
32981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32982         this_ptr_conv.is_owned = false;
32983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32984         LDKThirtyTwoBytes val_ref;
32985         CHECK((*env)->GetArrayLength(env, val) == 32);
32986         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32987         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
32988 }
32989
32990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32991         LDKAnnouncementSignatures this_ptr_conv;
32992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32993         this_ptr_conv.is_owned = false;
32994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32995         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
32996         return ret_conv;
32997 }
32998
32999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33000         LDKAnnouncementSignatures this_ptr_conv;
33001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33002         this_ptr_conv.is_owned = false;
33003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33004         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
33005 }
33006
33007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33008         LDKAnnouncementSignatures 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33013         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
33014         return ret_arr;
33015 }
33016
33017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33018         LDKAnnouncementSignatures this_ptr_conv;
33019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33020         this_ptr_conv.is_owned = false;
33021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33022         LDKSignature val_ref;
33023         CHECK((*env)->GetArrayLength(env, val) == 64);
33024         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33025         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
33026 }
33027
33028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33029         LDKAnnouncementSignatures this_ptr_conv;
33030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33031         this_ptr_conv.is_owned = false;
33032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33033         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33034         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
33035         return ret_arr;
33036 }
33037
33038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33039         LDKAnnouncementSignatures this_ptr_conv;
33040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33041         this_ptr_conv.is_owned = false;
33042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33043         LDKSignature val_ref;
33044         CHECK((*env)->GetArrayLength(env, val) == 64);
33045         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33046         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
33047 }
33048
33049 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) {
33050         LDKThirtyTwoBytes channel_id_arg_ref;
33051         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33052         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33053         LDKSignature node_signature_arg_ref;
33054         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
33055         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
33056         LDKSignature bitcoin_signature_arg_ref;
33057         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
33058         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
33059         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
33060         int64_t ret_ref = 0;
33061         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33062         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33064         ret_ref = (uintptr_t)ret_var.inner;
33065         if (ret_var.is_owned) {
33066                 ret_ref |= 1;
33067         }
33068         return ret_ref;
33069 }
33070
33071 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
33072         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
33073 int64_t ret_ref = 0;
33074 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33075 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33076 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33077 ret_ref = (uintptr_t)ret_var.inner;
33078 if (ret_var.is_owned) {
33079         ret_ref |= 1;
33080 }
33081         return ret_ref;
33082 }
33083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33084         LDKAnnouncementSignatures arg_conv;
33085         arg_conv.inner = (void*)(arg & (~1));
33086         arg_conv.is_owned = false;
33087         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33088         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
33089         return ret_conv;
33090 }
33091
33092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33093         LDKAnnouncementSignatures orig_conv;
33094         orig_conv.inner = (void*)(orig & (~1));
33095         orig_conv.is_owned = false;
33096         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33097         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
33098         int64_t ret_ref = 0;
33099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33102         ret_ref = (uintptr_t)ret_var.inner;
33103         if (ret_var.is_owned) {
33104                 ret_ref |= 1;
33105         }
33106         return ret_ref;
33107 }
33108
33109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33110         if ((this_ptr & 1) != 0) return;
33111         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33112         CHECK_ACCESS(this_ptr_ptr);
33113         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
33114         FREE((void*)this_ptr);
33115         NetAddress_free(this_ptr_conv);
33116 }
33117
33118 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
33119         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33120         *ret_copy = NetAddress_clone(arg);
33121 int64_t ret_ref = (uintptr_t)ret_copy;
33122         return ret_ref;
33123 }
33124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33125         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
33126         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
33127         return ret_conv;
33128 }
33129
33130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33131         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
33132         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33133         *ret_copy = NetAddress_clone(orig_conv);
33134         int64_t ret_ref = (uintptr_t)ret_copy;
33135         return ret_ref;
33136 }
33137
33138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
33139         LDKFourBytes addr_ref;
33140         CHECK((*env)->GetArrayLength(env, addr) == 4);
33141         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
33142         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33143         *ret_copy = NetAddress_ipv4(addr_ref, port);
33144         int64_t ret_ref = (uintptr_t)ret_copy;
33145         return ret_ref;
33146 }
33147
33148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
33149         LDKSixteenBytes addr_ref;
33150         CHECK((*env)->GetArrayLength(env, addr) == 16);
33151         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
33152         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33153         *ret_copy = NetAddress_ipv6(addr_ref, port);
33154         int64_t ret_ref = (uintptr_t)ret_copy;
33155         return ret_ref;
33156 }
33157
33158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
33159         LDKTwelveBytes a_ref;
33160         CHECK((*env)->GetArrayLength(env, a) == 12);
33161         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
33162         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33163         *ret_copy = NetAddress_onion_v2(a_ref);
33164         int64_t ret_ref = (uintptr_t)ret_copy;
33165         return ret_ref;
33166 }
33167
33168 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) {
33169         LDKThirtyTwoBytes ed25519_pubkey_ref;
33170         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
33171         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
33172         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
33173         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
33174         int64_t ret_ref = (uintptr_t)ret_copy;
33175         return ret_ref;
33176 }
33177
33178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
33179         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
33180         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
33181         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33182         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33183         CVec_u8Z_free(ret_var);
33184         return ret_arr;
33185 }
33186
33187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33188         LDKu8slice ser_ref;
33189         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33190         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33191         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
33192         *ret_conv = NetAddress_read(ser_ref);
33193         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33194         return (int64_t)ret_conv;
33195 }
33196
33197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33198         LDKUnsignedNodeAnnouncement this_obj_conv;
33199         this_obj_conv.inner = (void*)(this_obj & (~1));
33200         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33202         UnsignedNodeAnnouncement_free(this_obj_conv);
33203 }
33204
33205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
33206         LDKUnsignedNodeAnnouncement 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         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
33211         int64_t ret_ref = 0;
33212         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33213         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33215         ret_ref = (uintptr_t)ret_var.inner;
33216         if (ret_var.is_owned) {
33217                 ret_ref |= 1;
33218         }
33219         return ret_ref;
33220 }
33221
33222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33223         LDKUnsignedNodeAnnouncement this_ptr_conv;
33224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33225         this_ptr_conv.is_owned = false;
33226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33227         LDKNodeFeatures val_conv;
33228         val_conv.inner = (void*)(val & (~1));
33229         val_conv.is_owned = (val & 1) || (val == 0);
33230         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33231         val_conv = NodeFeatures_clone(&val_conv);
33232         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
33233 }
33234
33235 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
33236         LDKUnsignedNodeAnnouncement this_ptr_conv;
33237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33238         this_ptr_conv.is_owned = false;
33239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33240         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
33241         return ret_conv;
33242 }
33243
33244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33245         LDKUnsignedNodeAnnouncement this_ptr_conv;
33246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33247         this_ptr_conv.is_owned = false;
33248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33249         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
33250 }
33251
33252 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33253         LDKUnsignedNodeAnnouncement this_ptr_conv;
33254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33255         this_ptr_conv.is_owned = false;
33256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33257         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33258         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
33259         return ret_arr;
33260 }
33261
33262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33263         LDKUnsignedNodeAnnouncement this_ptr_conv;
33264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33265         this_ptr_conv.is_owned = false;
33266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33267         LDKPublicKey val_ref;
33268         CHECK((*env)->GetArrayLength(env, val) == 33);
33269         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33270         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
33271 }
33272
33273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
33274         LDKUnsignedNodeAnnouncement this_ptr_conv;
33275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33276         this_ptr_conv.is_owned = false;
33277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33278         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
33279         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
33280         return ret_arr;
33281 }
33282
33283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33284         LDKUnsignedNodeAnnouncement this_ptr_conv;
33285         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33286         this_ptr_conv.is_owned = false;
33287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33288         LDKThreeBytes val_ref;
33289         CHECK((*env)->GetArrayLength(env, val) == 3);
33290         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
33291         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
33292 }
33293
33294 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
33295         LDKUnsignedNodeAnnouncement this_ptr_conv;
33296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33297         this_ptr_conv.is_owned = false;
33298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33299         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33300         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
33301         return ret_arr;
33302 }
33303
33304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33305         LDKUnsignedNodeAnnouncement this_ptr_conv;
33306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33307         this_ptr_conv.is_owned = false;
33308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33309         LDKThirtyTwoBytes val_ref;
33310         CHECK((*env)->GetArrayLength(env, val) == 32);
33311         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33312         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
33313 }
33314
33315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
33316         LDKUnsignedNodeAnnouncement this_ptr_conv;
33317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33318         this_ptr_conv.is_owned = false;
33319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33320         LDKCVec_NetAddressZ val_constr;
33321         val_constr.datalen = (*env)->GetArrayLength(env, val);
33322         if (val_constr.datalen > 0)
33323                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
33324         else
33325                 val_constr.data = NULL;
33326         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
33327         for (size_t m = 0; m < val_constr.datalen; m++) {
33328                 int64_t val_conv_12 = val_vals[m];
33329                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
33330                 CHECK_ACCESS(val_conv_12_ptr);
33331                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
33332                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
33333                 val_constr.data[m] = val_conv_12_conv;
33334         }
33335         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
33336         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
33337 }
33338
33339 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
33340         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
33341 int64_t ret_ref = 0;
33342 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33343 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33344 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33345 ret_ref = (uintptr_t)ret_var.inner;
33346 if (ret_var.is_owned) {
33347         ret_ref |= 1;
33348 }
33349         return ret_ref;
33350 }
33351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33352         LDKUnsignedNodeAnnouncement arg_conv;
33353         arg_conv.inner = (void*)(arg & (~1));
33354         arg_conv.is_owned = false;
33355         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33356         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
33357         return ret_conv;
33358 }
33359
33360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33361         LDKUnsignedNodeAnnouncement orig_conv;
33362         orig_conv.inner = (void*)(orig & (~1));
33363         orig_conv.is_owned = false;
33364         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33365         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
33366         int64_t ret_ref = 0;
33367         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33368         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33370         ret_ref = (uintptr_t)ret_var.inner;
33371         if (ret_var.is_owned) {
33372                 ret_ref |= 1;
33373         }
33374         return ret_ref;
33375 }
33376
33377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33378         LDKNodeAnnouncement this_obj_conv;
33379         this_obj_conv.inner = (void*)(this_obj & (~1));
33380         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33382         NodeAnnouncement_free(this_obj_conv);
33383 }
33384
33385 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33386         LDKNodeAnnouncement this_ptr_conv;
33387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33388         this_ptr_conv.is_owned = false;
33389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33390         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33391         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
33392         return ret_arr;
33393 }
33394
33395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33396         LDKNodeAnnouncement this_ptr_conv;
33397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33398         this_ptr_conv.is_owned = false;
33399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33400         LDKSignature val_ref;
33401         CHECK((*env)->GetArrayLength(env, val) == 64);
33402         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33403         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
33404 }
33405
33406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
33407         LDKNodeAnnouncement this_ptr_conv;
33408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33409         this_ptr_conv.is_owned = false;
33410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33411         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
33412         int64_t ret_ref = 0;
33413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33416         ret_ref = (uintptr_t)ret_var.inner;
33417         if (ret_var.is_owned) {
33418                 ret_ref |= 1;
33419         }
33420         return ret_ref;
33421 }
33422
33423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33424         LDKNodeAnnouncement this_ptr_conv;
33425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33426         this_ptr_conv.is_owned = false;
33427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33428         LDKUnsignedNodeAnnouncement val_conv;
33429         val_conv.inner = (void*)(val & (~1));
33430         val_conv.is_owned = (val & 1) || (val == 0);
33431         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33432         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
33433         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
33434 }
33435
33436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
33437         LDKSignature signature_arg_ref;
33438         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33439         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33440         LDKUnsignedNodeAnnouncement contents_arg_conv;
33441         contents_arg_conv.inner = (void*)(contents_arg & (~1));
33442         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
33443         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
33444         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
33445         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
33446         int64_t ret_ref = 0;
33447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33450         ret_ref = (uintptr_t)ret_var.inner;
33451         if (ret_var.is_owned) {
33452                 ret_ref |= 1;
33453         }
33454         return ret_ref;
33455 }
33456
33457 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
33458         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
33459 int64_t ret_ref = 0;
33460 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33461 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33462 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33463 ret_ref = (uintptr_t)ret_var.inner;
33464 if (ret_var.is_owned) {
33465         ret_ref |= 1;
33466 }
33467         return ret_ref;
33468 }
33469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33470         LDKNodeAnnouncement arg_conv;
33471         arg_conv.inner = (void*)(arg & (~1));
33472         arg_conv.is_owned = false;
33473         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33474         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
33475         return ret_conv;
33476 }
33477
33478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33479         LDKNodeAnnouncement orig_conv;
33480         orig_conv.inner = (void*)(orig & (~1));
33481         orig_conv.is_owned = false;
33482         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33483         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
33484         int64_t ret_ref = 0;
33485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33488         ret_ref = (uintptr_t)ret_var.inner;
33489         if (ret_var.is_owned) {
33490                 ret_ref |= 1;
33491         }
33492         return ret_ref;
33493 }
33494
33495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33496         LDKUnsignedChannelAnnouncement this_obj_conv;
33497         this_obj_conv.inner = (void*)(this_obj & (~1));
33498         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33500         UnsignedChannelAnnouncement_free(this_obj_conv);
33501 }
33502
33503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
33504         LDKUnsignedChannelAnnouncement this_ptr_conv;
33505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33506         this_ptr_conv.is_owned = false;
33507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33508         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
33509         int64_t ret_ref = 0;
33510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33513         ret_ref = (uintptr_t)ret_var.inner;
33514         if (ret_var.is_owned) {
33515                 ret_ref |= 1;
33516         }
33517         return ret_ref;
33518 }
33519
33520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33521         LDKUnsignedChannelAnnouncement this_ptr_conv;
33522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33523         this_ptr_conv.is_owned = false;
33524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33525         LDKChannelFeatures val_conv;
33526         val_conv.inner = (void*)(val & (~1));
33527         val_conv.is_owned = (val & 1) || (val == 0);
33528         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33529         val_conv = ChannelFeatures_clone(&val_conv);
33530         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
33531 }
33532
33533 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33534         LDKUnsignedChannelAnnouncement this_ptr_conv;
33535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33536         this_ptr_conv.is_owned = false;
33537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33538         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33539         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
33540         return ret_arr;
33541 }
33542
33543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33544         LDKUnsignedChannelAnnouncement 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         LDKThirtyTwoBytes val_ref;
33549         CHECK((*env)->GetArrayLength(env, val) == 32);
33550         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33551         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
33552 }
33553
33554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33555         LDKUnsignedChannelAnnouncement this_ptr_conv;
33556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33557         this_ptr_conv.is_owned = false;
33558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33559         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
33560         return ret_conv;
33561 }
33562
33563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33564         LDKUnsignedChannelAnnouncement this_ptr_conv;
33565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33566         this_ptr_conv.is_owned = false;
33567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33568         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
33569 }
33570
33571 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33572         LDKUnsignedChannelAnnouncement this_ptr_conv;
33573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33574         this_ptr_conv.is_owned = false;
33575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33576         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33577         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
33578         return ret_arr;
33579 }
33580
33581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33582         LDKUnsignedChannelAnnouncement this_ptr_conv;
33583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33584         this_ptr_conv.is_owned = false;
33585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33586         LDKPublicKey val_ref;
33587         CHECK((*env)->GetArrayLength(env, val) == 33);
33588         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33589         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
33590 }
33591
33592 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33593         LDKUnsignedChannelAnnouncement this_ptr_conv;
33594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33595         this_ptr_conv.is_owned = false;
33596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33597         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33598         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
33599         return ret_arr;
33600 }
33601
33602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33603         LDKUnsignedChannelAnnouncement this_ptr_conv;
33604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33605         this_ptr_conv.is_owned = false;
33606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33607         LDKPublicKey val_ref;
33608         CHECK((*env)->GetArrayLength(env, val) == 33);
33609         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33610         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
33611 }
33612
33613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33614         LDKUnsignedChannelAnnouncement this_ptr_conv;
33615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33616         this_ptr_conv.is_owned = false;
33617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33618         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33619         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
33620         return ret_arr;
33621 }
33622
33623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33624         LDKUnsignedChannelAnnouncement this_ptr_conv;
33625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33626         this_ptr_conv.is_owned = false;
33627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33628         LDKPublicKey val_ref;
33629         CHECK((*env)->GetArrayLength(env, val) == 33);
33630         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33631         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
33632 }
33633
33634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33635         LDKUnsignedChannelAnnouncement this_ptr_conv;
33636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33637         this_ptr_conv.is_owned = false;
33638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33639         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33640         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
33641         return ret_arr;
33642 }
33643
33644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33645         LDKUnsignedChannelAnnouncement this_ptr_conv;
33646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33647         this_ptr_conv.is_owned = false;
33648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33649         LDKPublicKey val_ref;
33650         CHECK((*env)->GetArrayLength(env, val) == 33);
33651         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33652         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
33653 }
33654
33655 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
33656         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
33657 int64_t ret_ref = 0;
33658 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33659 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33660 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33661 ret_ref = (uintptr_t)ret_var.inner;
33662 if (ret_var.is_owned) {
33663         ret_ref |= 1;
33664 }
33665         return ret_ref;
33666 }
33667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33668         LDKUnsignedChannelAnnouncement arg_conv;
33669         arg_conv.inner = (void*)(arg & (~1));
33670         arg_conv.is_owned = false;
33671         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33672         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
33673         return ret_conv;
33674 }
33675
33676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33677         LDKUnsignedChannelAnnouncement orig_conv;
33678         orig_conv.inner = (void*)(orig & (~1));
33679         orig_conv.is_owned = false;
33680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33681         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
33682         int64_t ret_ref = 0;
33683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33686         ret_ref = (uintptr_t)ret_var.inner;
33687         if (ret_var.is_owned) {
33688                 ret_ref |= 1;
33689         }
33690         return ret_ref;
33691 }
33692
33693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33694         LDKChannelAnnouncement this_obj_conv;
33695         this_obj_conv.inner = (void*)(this_obj & (~1));
33696         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33698         ChannelAnnouncement_free(this_obj_conv);
33699 }
33700
33701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33702         LDKChannelAnnouncement this_ptr_conv;
33703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33704         this_ptr_conv.is_owned = false;
33705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33706         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33707         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
33708         return ret_arr;
33709 }
33710
33711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33712         LDKChannelAnnouncement this_ptr_conv;
33713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33714         this_ptr_conv.is_owned = false;
33715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33716         LDKSignature val_ref;
33717         CHECK((*env)->GetArrayLength(env, val) == 64);
33718         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33719         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
33720 }
33721
33722 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33723         LDKChannelAnnouncement this_ptr_conv;
33724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33725         this_ptr_conv.is_owned = false;
33726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33727         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33728         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
33729         return ret_arr;
33730 }
33731
33732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33733         LDKChannelAnnouncement this_ptr_conv;
33734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33735         this_ptr_conv.is_owned = false;
33736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33737         LDKSignature val_ref;
33738         CHECK((*env)->GetArrayLength(env, val) == 64);
33739         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33740         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
33741 }
33742
33743 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
33744         LDKChannelAnnouncement this_ptr_conv;
33745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33746         this_ptr_conv.is_owned = false;
33747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33748         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33749         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
33750         return ret_arr;
33751 }
33752
33753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33754         LDKChannelAnnouncement this_ptr_conv;
33755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33756         this_ptr_conv.is_owned = false;
33757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33758         LDKSignature val_ref;
33759         CHECK((*env)->GetArrayLength(env, val) == 64);
33760         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33761         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
33762 }
33763
33764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
33765         LDKChannelAnnouncement this_ptr_conv;
33766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33767         this_ptr_conv.is_owned = false;
33768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33769         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33770         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
33771         return ret_arr;
33772 }
33773
33774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33775         LDKChannelAnnouncement this_ptr_conv;
33776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33777         this_ptr_conv.is_owned = false;
33778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33779         LDKSignature val_ref;
33780         CHECK((*env)->GetArrayLength(env, val) == 64);
33781         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33782         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
33783 }
33784
33785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
33786         LDKChannelAnnouncement this_ptr_conv;
33787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33788         this_ptr_conv.is_owned = false;
33789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33790         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
33791         int64_t ret_ref = 0;
33792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33795         ret_ref = (uintptr_t)ret_var.inner;
33796         if (ret_var.is_owned) {
33797                 ret_ref |= 1;
33798         }
33799         return ret_ref;
33800 }
33801
33802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33803         LDKChannelAnnouncement this_ptr_conv;
33804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33805         this_ptr_conv.is_owned = false;
33806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33807         LDKUnsignedChannelAnnouncement val_conv;
33808         val_conv.inner = (void*)(val & (~1));
33809         val_conv.is_owned = (val & 1) || (val == 0);
33810         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33811         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
33812         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
33813 }
33814
33815 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) {
33816         LDKSignature node_signature_1_arg_ref;
33817         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
33818         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
33819         LDKSignature node_signature_2_arg_ref;
33820         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
33821         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
33822         LDKSignature bitcoin_signature_1_arg_ref;
33823         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
33824         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
33825         LDKSignature bitcoin_signature_2_arg_ref;
33826         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
33827         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
33828         LDKUnsignedChannelAnnouncement contents_arg_conv;
33829         contents_arg_conv.inner = (void*)(contents_arg & (~1));
33830         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
33831         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
33832         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
33833         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);
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
33845 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
33846         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
33847 int64_t ret_ref = 0;
33848 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33849 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33850 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33851 ret_ref = (uintptr_t)ret_var.inner;
33852 if (ret_var.is_owned) {
33853         ret_ref |= 1;
33854 }
33855         return ret_ref;
33856 }
33857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33858         LDKChannelAnnouncement arg_conv;
33859         arg_conv.inner = (void*)(arg & (~1));
33860         arg_conv.is_owned = false;
33861         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33862         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
33863         return ret_conv;
33864 }
33865
33866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33867         LDKChannelAnnouncement orig_conv;
33868         orig_conv.inner = (void*)(orig & (~1));
33869         orig_conv.is_owned = false;
33870         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33871         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
33872         int64_t ret_ref = 0;
33873         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33874         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33876         ret_ref = (uintptr_t)ret_var.inner;
33877         if (ret_var.is_owned) {
33878                 ret_ref |= 1;
33879         }
33880         return ret_ref;
33881 }
33882
33883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33884         LDKUnsignedChannelUpdate this_obj_conv;
33885         this_obj_conv.inner = (void*)(this_obj & (~1));
33886         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33888         UnsignedChannelUpdate_free(this_obj_conv);
33889 }
33890
33891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
33892         LDKUnsignedChannelUpdate this_ptr_conv;
33893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33894         this_ptr_conv.is_owned = false;
33895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33896         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33897         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
33898         return ret_arr;
33899 }
33900
33901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33902         LDKUnsignedChannelUpdate this_ptr_conv;
33903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33904         this_ptr_conv.is_owned = false;
33905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33906         LDKThirtyTwoBytes val_ref;
33907         CHECK((*env)->GetArrayLength(env, val) == 32);
33908         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33909         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
33910 }
33911
33912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33913         LDKUnsignedChannelUpdate this_ptr_conv;
33914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33915         this_ptr_conv.is_owned = false;
33916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33917         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
33918         return ret_conv;
33919 }
33920
33921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33922         LDKUnsignedChannelUpdate this_ptr_conv;
33923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33924         this_ptr_conv.is_owned = false;
33925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33926         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
33927 }
33928
33929 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
33930         LDKUnsignedChannelUpdate this_ptr_conv;
33931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33932         this_ptr_conv.is_owned = false;
33933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33934         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
33935         return ret_conv;
33936 }
33937
33938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33939         LDKUnsignedChannelUpdate this_ptr_conv;
33940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33941         this_ptr_conv.is_owned = false;
33942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33943         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
33944 }
33945
33946 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
33947         LDKUnsignedChannelUpdate this_ptr_conv;
33948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33949         this_ptr_conv.is_owned = false;
33950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33951         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
33952         return ret_conv;
33953 }
33954
33955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
33956         LDKUnsignedChannelUpdate this_ptr_conv;
33957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33958         this_ptr_conv.is_owned = false;
33959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33960         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
33961 }
33962
33963 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
33964         LDKUnsignedChannelUpdate this_ptr_conv;
33965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33966         this_ptr_conv.is_owned = false;
33967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33968         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
33969         return ret_conv;
33970 }
33971
33972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33973         LDKUnsignedChannelUpdate this_ptr_conv;
33974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33975         this_ptr_conv.is_owned = false;
33976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33977         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
33978 }
33979
33980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33981         LDKUnsignedChannelUpdate this_ptr_conv;
33982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33983         this_ptr_conv.is_owned = false;
33984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33985         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
33986         return ret_conv;
33987 }
33988
33989 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33990         LDKUnsignedChannelUpdate this_ptr_conv;
33991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33992         this_ptr_conv.is_owned = false;
33993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33994         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
33995 }
33996
33997 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33998         LDKUnsignedChannelUpdate this_ptr_conv;
33999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34000         this_ptr_conv.is_owned = false;
34001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34002         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
34003         return ret_conv;
34004 }
34005
34006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34007         LDKUnsignedChannelUpdate this_ptr_conv;
34008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34009         this_ptr_conv.is_owned = false;
34010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34011         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
34012 }
34013
34014 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
34015         LDKUnsignedChannelUpdate this_ptr_conv;
34016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34017         this_ptr_conv.is_owned = false;
34018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34019         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
34020         return ret_conv;
34021 }
34022
34023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34024         LDKUnsignedChannelUpdate this_ptr_conv;
34025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34026         this_ptr_conv.is_owned = false;
34027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34028         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
34029 }
34030
34031 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
34032         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
34033 int64_t ret_ref = 0;
34034 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34035 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34036 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34037 ret_ref = (uintptr_t)ret_var.inner;
34038 if (ret_var.is_owned) {
34039         ret_ref |= 1;
34040 }
34041         return ret_ref;
34042 }
34043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34044         LDKUnsignedChannelUpdate arg_conv;
34045         arg_conv.inner = (void*)(arg & (~1));
34046         arg_conv.is_owned = false;
34047         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34048         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
34049         return ret_conv;
34050 }
34051
34052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34053         LDKUnsignedChannelUpdate orig_conv;
34054         orig_conv.inner = (void*)(orig & (~1));
34055         orig_conv.is_owned = false;
34056         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34057         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
34058         int64_t ret_ref = 0;
34059         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34060         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34062         ret_ref = (uintptr_t)ret_var.inner;
34063         if (ret_var.is_owned) {
34064                 ret_ref |= 1;
34065         }
34066         return ret_ref;
34067 }
34068
34069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34070         LDKChannelUpdate this_obj_conv;
34071         this_obj_conv.inner = (void*)(this_obj & (~1));
34072         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34074         ChannelUpdate_free(this_obj_conv);
34075 }
34076
34077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34078         LDKChannelUpdate this_ptr_conv;
34079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34080         this_ptr_conv.is_owned = false;
34081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34082         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34083         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
34084         return ret_arr;
34085 }
34086
34087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34088         LDKChannelUpdate this_ptr_conv;
34089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34090         this_ptr_conv.is_owned = false;
34091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34092         LDKSignature val_ref;
34093         CHECK((*env)->GetArrayLength(env, val) == 64);
34094         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34095         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
34096 }
34097
34098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
34099         LDKChannelUpdate this_ptr_conv;
34100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34101         this_ptr_conv.is_owned = false;
34102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34103         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
34104         int64_t ret_ref = 0;
34105         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34106         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34108         ret_ref = (uintptr_t)ret_var.inner;
34109         if (ret_var.is_owned) {
34110                 ret_ref |= 1;
34111         }
34112         return ret_ref;
34113 }
34114
34115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34116         LDKChannelUpdate 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         LDKUnsignedChannelUpdate val_conv;
34121         val_conv.inner = (void*)(val & (~1));
34122         val_conv.is_owned = (val & 1) || (val == 0);
34123         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34124         val_conv = UnsignedChannelUpdate_clone(&val_conv);
34125         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
34126 }
34127
34128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
34129         LDKSignature signature_arg_ref;
34130         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34131         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34132         LDKUnsignedChannelUpdate contents_arg_conv;
34133         contents_arg_conv.inner = (void*)(contents_arg & (~1));
34134         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
34135         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
34136         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
34137         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
34138         int64_t ret_ref = 0;
34139         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34140         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34142         ret_ref = (uintptr_t)ret_var.inner;
34143         if (ret_var.is_owned) {
34144                 ret_ref |= 1;
34145         }
34146         return ret_ref;
34147 }
34148
34149 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
34150         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
34151 int64_t ret_ref = 0;
34152 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34153 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34154 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34155 ret_ref = (uintptr_t)ret_var.inner;
34156 if (ret_var.is_owned) {
34157         ret_ref |= 1;
34158 }
34159         return ret_ref;
34160 }
34161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34162         LDKChannelUpdate arg_conv;
34163         arg_conv.inner = (void*)(arg & (~1));
34164         arg_conv.is_owned = false;
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34166         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
34167         return ret_conv;
34168 }
34169
34170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34171         LDKChannelUpdate orig_conv;
34172         orig_conv.inner = (void*)(orig & (~1));
34173         orig_conv.is_owned = false;
34174         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34175         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
34176         int64_t ret_ref = 0;
34177         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34178         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34180         ret_ref = (uintptr_t)ret_var.inner;
34181         if (ret_var.is_owned) {
34182                 ret_ref |= 1;
34183         }
34184         return ret_ref;
34185 }
34186
34187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34188         LDKQueryChannelRange this_obj_conv;
34189         this_obj_conv.inner = (void*)(this_obj & (~1));
34190         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34192         QueryChannelRange_free(this_obj_conv);
34193 }
34194
34195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34196         LDKQueryChannelRange this_ptr_conv;
34197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34198         this_ptr_conv.is_owned = false;
34199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34200         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
34202         return ret_arr;
34203 }
34204
34205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34206         LDKQueryChannelRange this_ptr_conv;
34207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34208         this_ptr_conv.is_owned = false;
34209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34210         LDKThirtyTwoBytes val_ref;
34211         CHECK((*env)->GetArrayLength(env, val) == 32);
34212         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34213         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
34214 }
34215
34216 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
34217         LDKQueryChannelRange 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         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
34222         return ret_conv;
34223 }
34224
34225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34226         LDKQueryChannelRange this_ptr_conv;
34227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34228         this_ptr_conv.is_owned = false;
34229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34230         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
34231 }
34232
34233 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
34234         LDKQueryChannelRange this_ptr_conv;
34235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34236         this_ptr_conv.is_owned = false;
34237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34238         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
34239         return ret_conv;
34240 }
34241
34242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34243         LDKQueryChannelRange this_ptr_conv;
34244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34245         this_ptr_conv.is_owned = false;
34246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34247         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
34248 }
34249
34250 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) {
34251         LDKThirtyTwoBytes chain_hash_arg_ref;
34252         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34253         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34254         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
34255         int64_t ret_ref = 0;
34256         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34257         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34259         ret_ref = (uintptr_t)ret_var.inner;
34260         if (ret_var.is_owned) {
34261                 ret_ref |= 1;
34262         }
34263         return ret_ref;
34264 }
34265
34266 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
34267         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
34268 int64_t ret_ref = 0;
34269 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34270 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34271 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34272 ret_ref = (uintptr_t)ret_var.inner;
34273 if (ret_var.is_owned) {
34274         ret_ref |= 1;
34275 }
34276         return ret_ref;
34277 }
34278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34279         LDKQueryChannelRange arg_conv;
34280         arg_conv.inner = (void*)(arg & (~1));
34281         arg_conv.is_owned = false;
34282         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34283         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
34284         return ret_conv;
34285 }
34286
34287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34288         LDKQueryChannelRange orig_conv;
34289         orig_conv.inner = (void*)(orig & (~1));
34290         orig_conv.is_owned = false;
34291         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34292         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
34293         int64_t ret_ref = 0;
34294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34297         ret_ref = (uintptr_t)ret_var.inner;
34298         if (ret_var.is_owned) {
34299                 ret_ref |= 1;
34300         }
34301         return ret_ref;
34302 }
34303
34304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34305         LDKReplyChannelRange this_obj_conv;
34306         this_obj_conv.inner = (void*)(this_obj & (~1));
34307         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34309         ReplyChannelRange_free(this_obj_conv);
34310 }
34311
34312 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34313         LDKReplyChannelRange this_ptr_conv;
34314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34315         this_ptr_conv.is_owned = false;
34316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34317         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34318         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
34319         return ret_arr;
34320 }
34321
34322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34323         LDKReplyChannelRange this_ptr_conv;
34324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34325         this_ptr_conv.is_owned = false;
34326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34327         LDKThirtyTwoBytes val_ref;
34328         CHECK((*env)->GetArrayLength(env, val) == 32);
34329         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34330         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
34331 }
34332
34333 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
34334         LDKReplyChannelRange this_ptr_conv;
34335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34336         this_ptr_conv.is_owned = false;
34337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34338         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
34339         return ret_conv;
34340 }
34341
34342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34343         LDKReplyChannelRange this_ptr_conv;
34344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34345         this_ptr_conv.is_owned = false;
34346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34347         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
34348 }
34349
34350 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
34351         LDKReplyChannelRange this_ptr_conv;
34352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34353         this_ptr_conv.is_owned = false;
34354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34355         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
34356         return ret_conv;
34357 }
34358
34359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34360         LDKReplyChannelRange this_ptr_conv;
34361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34362         this_ptr_conv.is_owned = false;
34363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34364         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
34365 }
34366
34367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
34368         LDKReplyChannelRange this_ptr_conv;
34369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34370         this_ptr_conv.is_owned = false;
34371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34372         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
34373         return ret_conv;
34374 }
34375
34376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34377         LDKReplyChannelRange this_ptr_conv;
34378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34379         this_ptr_conv.is_owned = false;
34380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34381         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
34382 }
34383
34384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34385         LDKReplyChannelRange this_ptr_conv;
34386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34387         this_ptr_conv.is_owned = false;
34388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34389         LDKCVec_u64Z val_constr;
34390         val_constr.datalen = (*env)->GetArrayLength(env, val);
34391         if (val_constr.datalen > 0)
34392                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34393         else
34394                 val_constr.data = NULL;
34395         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34396         for (size_t g = 0; g < val_constr.datalen; g++) {
34397                 int64_t val_conv_6 = val_vals[g];
34398                 val_constr.data[g] = val_conv_6;
34399         }
34400         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34401         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
34402 }
34403
34404 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) {
34405         LDKThirtyTwoBytes chain_hash_arg_ref;
34406         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34407         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34408         LDKCVec_u64Z short_channel_ids_arg_constr;
34409         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
34410         if (short_channel_ids_arg_constr.datalen > 0)
34411                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34412         else
34413                 short_channel_ids_arg_constr.data = NULL;
34414         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
34415         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
34416                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
34417                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
34418         }
34419         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
34420         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
34421         int64_t ret_ref = 0;
34422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34425         ret_ref = (uintptr_t)ret_var.inner;
34426         if (ret_var.is_owned) {
34427                 ret_ref |= 1;
34428         }
34429         return ret_ref;
34430 }
34431
34432 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
34433         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
34434 int64_t ret_ref = 0;
34435 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34436 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34437 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34438 ret_ref = (uintptr_t)ret_var.inner;
34439 if (ret_var.is_owned) {
34440         ret_ref |= 1;
34441 }
34442         return ret_ref;
34443 }
34444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34445         LDKReplyChannelRange arg_conv;
34446         arg_conv.inner = (void*)(arg & (~1));
34447         arg_conv.is_owned = false;
34448         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34449         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
34450         return ret_conv;
34451 }
34452
34453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34454         LDKReplyChannelRange orig_conv;
34455         orig_conv.inner = (void*)(orig & (~1));
34456         orig_conv.is_owned = false;
34457         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34458         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
34459         int64_t ret_ref = 0;
34460         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34461         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34463         ret_ref = (uintptr_t)ret_var.inner;
34464         if (ret_var.is_owned) {
34465                 ret_ref |= 1;
34466         }
34467         return ret_ref;
34468 }
34469
34470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34471         LDKQueryShortChannelIds this_obj_conv;
34472         this_obj_conv.inner = (void*)(this_obj & (~1));
34473         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34475         QueryShortChannelIds_free(this_obj_conv);
34476 }
34477
34478 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34479         LDKQueryShortChannelIds this_ptr_conv;
34480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34481         this_ptr_conv.is_owned = false;
34482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34483         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34484         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
34485         return ret_arr;
34486 }
34487
34488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34489         LDKQueryShortChannelIds this_ptr_conv;
34490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34491         this_ptr_conv.is_owned = false;
34492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34493         LDKThirtyTwoBytes val_ref;
34494         CHECK((*env)->GetArrayLength(env, val) == 32);
34495         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34496         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
34497 }
34498
34499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
34500         LDKQueryShortChannelIds this_ptr_conv;
34501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34502         this_ptr_conv.is_owned = false;
34503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34504         LDKCVec_u64Z val_constr;
34505         val_constr.datalen = (*env)->GetArrayLength(env, val);
34506         if (val_constr.datalen > 0)
34507                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34508         else
34509                 val_constr.data = NULL;
34510         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
34511         for (size_t g = 0; g < val_constr.datalen; g++) {
34512                 int64_t val_conv_6 = val_vals[g];
34513                 val_constr.data[g] = val_conv_6;
34514         }
34515         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
34516         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
34517 }
34518
34519 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) {
34520         LDKThirtyTwoBytes chain_hash_arg_ref;
34521         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34522         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34523         LDKCVec_u64Z short_channel_ids_arg_constr;
34524         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
34525         if (short_channel_ids_arg_constr.datalen > 0)
34526                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
34527         else
34528                 short_channel_ids_arg_constr.data = NULL;
34529         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
34530         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
34531                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
34532                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
34533         }
34534         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
34535         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
34536         int64_t ret_ref = 0;
34537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34540         ret_ref = (uintptr_t)ret_var.inner;
34541         if (ret_var.is_owned) {
34542                 ret_ref |= 1;
34543         }
34544         return ret_ref;
34545 }
34546
34547 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
34548         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
34549 int64_t ret_ref = 0;
34550 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34551 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34552 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34553 ret_ref = (uintptr_t)ret_var.inner;
34554 if (ret_var.is_owned) {
34555         ret_ref |= 1;
34556 }
34557         return ret_ref;
34558 }
34559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34560         LDKQueryShortChannelIds arg_conv;
34561         arg_conv.inner = (void*)(arg & (~1));
34562         arg_conv.is_owned = false;
34563         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34564         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
34565         return ret_conv;
34566 }
34567
34568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34569         LDKQueryShortChannelIds orig_conv;
34570         orig_conv.inner = (void*)(orig & (~1));
34571         orig_conv.is_owned = false;
34572         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34573         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
34574         int64_t ret_ref = 0;
34575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34578         ret_ref = (uintptr_t)ret_var.inner;
34579         if (ret_var.is_owned) {
34580                 ret_ref |= 1;
34581         }
34582         return ret_ref;
34583 }
34584
34585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34586         LDKReplyShortChannelIdsEnd this_obj_conv;
34587         this_obj_conv.inner = (void*)(this_obj & (~1));
34588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34590         ReplyShortChannelIdsEnd_free(this_obj_conv);
34591 }
34592
34593 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34594         LDKReplyShortChannelIdsEnd this_ptr_conv;
34595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34596         this_ptr_conv.is_owned = false;
34597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34598         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34599         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
34600         return ret_arr;
34601 }
34602
34603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34604         LDKReplyShortChannelIdsEnd this_ptr_conv;
34605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34606         this_ptr_conv.is_owned = false;
34607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34608         LDKThirtyTwoBytes val_ref;
34609         CHECK((*env)->GetArrayLength(env, val) == 32);
34610         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34611         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
34612 }
34613
34614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
34615         LDKReplyShortChannelIdsEnd this_ptr_conv;
34616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34617         this_ptr_conv.is_owned = false;
34618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34619         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
34620         return ret_conv;
34621 }
34622
34623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34624         LDKReplyShortChannelIdsEnd 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         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
34629 }
34630
34631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
34632         LDKThirtyTwoBytes chain_hash_arg_ref;
34633         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34634         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34635         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
34636         int64_t ret_ref = 0;
34637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34640         ret_ref = (uintptr_t)ret_var.inner;
34641         if (ret_var.is_owned) {
34642                 ret_ref |= 1;
34643         }
34644         return ret_ref;
34645 }
34646
34647 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
34648         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
34649 int64_t ret_ref = 0;
34650 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34651 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34652 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34653 ret_ref = (uintptr_t)ret_var.inner;
34654 if (ret_var.is_owned) {
34655         ret_ref |= 1;
34656 }
34657         return ret_ref;
34658 }
34659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34660         LDKReplyShortChannelIdsEnd arg_conv;
34661         arg_conv.inner = (void*)(arg & (~1));
34662         arg_conv.is_owned = false;
34663         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34664         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
34665         return ret_conv;
34666 }
34667
34668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34669         LDKReplyShortChannelIdsEnd orig_conv;
34670         orig_conv.inner = (void*)(orig & (~1));
34671         orig_conv.is_owned = false;
34672         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34673         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
34674         int64_t ret_ref = 0;
34675         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34676         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34678         ret_ref = (uintptr_t)ret_var.inner;
34679         if (ret_var.is_owned) {
34680                 ret_ref |= 1;
34681         }
34682         return ret_ref;
34683 }
34684
34685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34686         LDKGossipTimestampFilter this_obj_conv;
34687         this_obj_conv.inner = (void*)(this_obj & (~1));
34688         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34690         GossipTimestampFilter_free(this_obj_conv);
34691 }
34692
34693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34694         LDKGossipTimestampFilter this_ptr_conv;
34695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34696         this_ptr_conv.is_owned = false;
34697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34698         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34699         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
34700         return ret_arr;
34701 }
34702
34703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34704         LDKGossipTimestampFilter this_ptr_conv;
34705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34706         this_ptr_conv.is_owned = false;
34707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34708         LDKThirtyTwoBytes val_ref;
34709         CHECK((*env)->GetArrayLength(env, val) == 32);
34710         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34711         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
34712 }
34713
34714 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
34715         LDKGossipTimestampFilter this_ptr_conv;
34716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34717         this_ptr_conv.is_owned = false;
34718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34719         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
34720         return ret_conv;
34721 }
34722
34723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34724         LDKGossipTimestampFilter this_ptr_conv;
34725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34726         this_ptr_conv.is_owned = false;
34727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34728         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
34729 }
34730
34731 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
34732         LDKGossipTimestampFilter this_ptr_conv;
34733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34734         this_ptr_conv.is_owned = false;
34735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34736         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
34737         return ret_conv;
34738 }
34739
34740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34741         LDKGossipTimestampFilter this_ptr_conv;
34742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34743         this_ptr_conv.is_owned = false;
34744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34745         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
34746 }
34747
34748 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) {
34749         LDKThirtyTwoBytes chain_hash_arg_ref;
34750         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
34751         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
34752         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
34753         int64_t ret_ref = 0;
34754         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34755         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34757         ret_ref = (uintptr_t)ret_var.inner;
34758         if (ret_var.is_owned) {
34759                 ret_ref |= 1;
34760         }
34761         return ret_ref;
34762 }
34763
34764 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
34765         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
34766 int64_t ret_ref = 0;
34767 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34768 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34769 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34770 ret_ref = (uintptr_t)ret_var.inner;
34771 if (ret_var.is_owned) {
34772         ret_ref |= 1;
34773 }
34774         return ret_ref;
34775 }
34776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34777         LDKGossipTimestampFilter arg_conv;
34778         arg_conv.inner = (void*)(arg & (~1));
34779         arg_conv.is_owned = false;
34780         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34781         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
34782         return ret_conv;
34783 }
34784
34785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34786         LDKGossipTimestampFilter orig_conv;
34787         orig_conv.inner = (void*)(orig & (~1));
34788         orig_conv.is_owned = false;
34789         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34790         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
34791         int64_t ret_ref = 0;
34792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34795         ret_ref = (uintptr_t)ret_var.inner;
34796         if (ret_var.is_owned) {
34797                 ret_ref |= 1;
34798         }
34799         return ret_ref;
34800 }
34801
34802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34803         if ((this_ptr & 1) != 0) return;
34804         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34805         CHECK_ACCESS(this_ptr_ptr);
34806         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
34807         FREE((void*)this_ptr);
34808         ErrorAction_free(this_ptr_conv);
34809 }
34810
34811 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
34812         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34813         *ret_copy = ErrorAction_clone(arg);
34814 int64_t ret_ref = (uintptr_t)ret_copy;
34815         return ret_ref;
34816 }
34817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34818         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
34819         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
34820         return ret_conv;
34821 }
34822
34823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34824         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
34825         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34826         *ret_copy = ErrorAction_clone(orig_conv);
34827         int64_t ret_ref = (uintptr_t)ret_copy;
34828         return ret_ref;
34829 }
34830
34831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
34832         LDKErrorMessage msg_conv;
34833         msg_conv.inner = (void*)(msg & (~1));
34834         msg_conv.is_owned = (msg & 1) || (msg == 0);
34835         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34836         msg_conv = ErrorMessage_clone(&msg_conv);
34837         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34838         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
34839         int64_t ret_ref = (uintptr_t)ret_copy;
34840         return ret_ref;
34841 }
34842
34843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
34844         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34845         *ret_copy = ErrorAction_ignore_error();
34846         int64_t ret_ref = (uintptr_t)ret_copy;
34847         return ret_ref;
34848 }
34849
34850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
34851         LDKLevel a_conv = LDKLevel_from_java(env, a);
34852         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34853         *ret_copy = ErrorAction_ignore_and_log(a_conv);
34854         int64_t ret_ref = (uintptr_t)ret_copy;
34855         return ret_ref;
34856 }
34857
34858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
34859         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34860         *ret_copy = ErrorAction_ignore_duplicate_gossip();
34861         int64_t ret_ref = (uintptr_t)ret_copy;
34862         return ret_ref;
34863 }
34864
34865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
34866         LDKErrorMessage msg_conv;
34867         msg_conv.inner = (void*)(msg & (~1));
34868         msg_conv.is_owned = (msg & 1) || (msg == 0);
34869         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34870         msg_conv = ErrorMessage_clone(&msg_conv);
34871         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34872         *ret_copy = ErrorAction_send_error_message(msg_conv);
34873         int64_t ret_ref = (uintptr_t)ret_copy;
34874         return ret_ref;
34875 }
34876
34877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
34878         LDKWarningMessage msg_conv;
34879         msg_conv.inner = (void*)(msg & (~1));
34880         msg_conv.is_owned = (msg & 1) || (msg == 0);
34881         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34882         msg_conv = WarningMessage_clone(&msg_conv);
34883         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
34884         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34885         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
34886         int64_t ret_ref = (uintptr_t)ret_copy;
34887         return ret_ref;
34888 }
34889
34890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34891         LDKLightningError this_obj_conv;
34892         this_obj_conv.inner = (void*)(this_obj & (~1));
34893         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34895         LightningError_free(this_obj_conv);
34896 }
34897
34898 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
34899         LDKLightningError this_ptr_conv;
34900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34901         this_ptr_conv.is_owned = false;
34902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34903         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
34904         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34905         Str_free(ret_str);
34906         return ret_conv;
34907 }
34908
34909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34910         LDKLightningError this_ptr_conv;
34911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34912         this_ptr_conv.is_owned = false;
34913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34914         LDKStr val_conv = java_to_owned_str(env, val);
34915         LightningError_set_err(&this_ptr_conv, val_conv);
34916 }
34917
34918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
34919         LDKLightningError 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         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
34924         *ret_copy = LightningError_get_action(&this_ptr_conv);
34925         int64_t ret_ref = (uintptr_t)ret_copy;
34926         return ret_ref;
34927 }
34928
34929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34930         LDKLightningError this_ptr_conv;
34931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34932         this_ptr_conv.is_owned = false;
34933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34934         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34935         CHECK_ACCESS(val_ptr);
34936         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
34937         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
34938         LightningError_set_action(&this_ptr_conv, val_conv);
34939 }
34940
34941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
34942         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
34943         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
34944         CHECK_ACCESS(action_arg_ptr);
34945         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
34946         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
34947         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
34948         int64_t ret_ref = 0;
34949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34952         ret_ref = (uintptr_t)ret_var.inner;
34953         if (ret_var.is_owned) {
34954                 ret_ref |= 1;
34955         }
34956         return ret_ref;
34957 }
34958
34959 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
34960         LDKLightningError ret_var = LightningError_clone(arg);
34961 int64_t ret_ref = 0;
34962 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34963 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34964 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34965 ret_ref = (uintptr_t)ret_var.inner;
34966 if (ret_var.is_owned) {
34967         ret_ref |= 1;
34968 }
34969         return ret_ref;
34970 }
34971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34972         LDKLightningError arg_conv;
34973         arg_conv.inner = (void*)(arg & (~1));
34974         arg_conv.is_owned = false;
34975         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34976         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
34977         return ret_conv;
34978 }
34979
34980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34981         LDKLightningError orig_conv;
34982         orig_conv.inner = (void*)(orig & (~1));
34983         orig_conv.is_owned = false;
34984         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34985         LDKLightningError ret_var = LightningError_clone(&orig_conv);
34986         int64_t ret_ref = 0;
34987         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34988         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34990         ret_ref = (uintptr_t)ret_var.inner;
34991         if (ret_var.is_owned) {
34992                 ret_ref |= 1;
34993         }
34994         return ret_ref;
34995 }
34996
34997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34998         LDKCommitmentUpdate this_obj_conv;
34999         this_obj_conv.inner = (void*)(this_obj & (~1));
35000         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35002         CommitmentUpdate_free(this_obj_conv);
35003 }
35004
35005 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35006         LDKCommitmentUpdate this_ptr_conv;
35007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35008         this_ptr_conv.is_owned = false;
35009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35010         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
35011         int64_tArray ret_arr = NULL;
35012         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35013         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35014         for (size_t p = 0; p < ret_var.datalen; p++) {
35015                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
35016                 int64_t ret_conv_15_ref = 0;
35017                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35018                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35019                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
35020                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
35021                 if (ret_conv_15_var.is_owned) {
35022                         ret_conv_15_ref |= 1;
35023                 }
35024                 ret_arr_ptr[p] = ret_conv_15_ref;
35025         }
35026         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35027         FREE(ret_var.data);
35028         return ret_arr;
35029 }
35030
35031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35032         LDKCommitmentUpdate this_ptr_conv;
35033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35034         this_ptr_conv.is_owned = false;
35035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35036         LDKCVec_UpdateAddHTLCZ val_constr;
35037         val_constr.datalen = (*env)->GetArrayLength(env, val);
35038         if (val_constr.datalen > 0)
35039                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
35040         else
35041                 val_constr.data = NULL;
35042         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35043         for (size_t p = 0; p < val_constr.datalen; p++) {
35044                 int64_t val_conv_15 = val_vals[p];
35045                 LDKUpdateAddHTLC val_conv_15_conv;
35046                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
35047                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
35048                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
35049                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
35050                 val_constr.data[p] = val_conv_15_conv;
35051         }
35052         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35053         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
35054 }
35055
35056 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35057         LDKCommitmentUpdate this_ptr_conv;
35058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35059         this_ptr_conv.is_owned = false;
35060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35061         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
35062         int64_tArray ret_arr = NULL;
35063         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35064         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35065         for (size_t t = 0; t < ret_var.datalen; t++) {
35066                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
35067                 int64_t ret_conv_19_ref = 0;
35068                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35069                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35070                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
35071                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
35072                 if (ret_conv_19_var.is_owned) {
35073                         ret_conv_19_ref |= 1;
35074                 }
35075                 ret_arr_ptr[t] = ret_conv_19_ref;
35076         }
35077         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35078         FREE(ret_var.data);
35079         return ret_arr;
35080 }
35081
35082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35083         LDKCommitmentUpdate this_ptr_conv;
35084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35085         this_ptr_conv.is_owned = false;
35086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35087         LDKCVec_UpdateFulfillHTLCZ val_constr;
35088         val_constr.datalen = (*env)->GetArrayLength(env, val);
35089         if (val_constr.datalen > 0)
35090                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
35091         else
35092                 val_constr.data = NULL;
35093         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35094         for (size_t t = 0; t < val_constr.datalen; t++) {
35095                 int64_t val_conv_19 = val_vals[t];
35096                 LDKUpdateFulfillHTLC val_conv_19_conv;
35097                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
35098                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
35099                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
35100                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
35101                 val_constr.data[t] = val_conv_19_conv;
35102         }
35103         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35104         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
35105 }
35106
35107 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35108         LDKCommitmentUpdate this_ptr_conv;
35109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35110         this_ptr_conv.is_owned = false;
35111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35112         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
35113         int64_tArray ret_arr = NULL;
35114         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35115         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35116         for (size_t q = 0; q < ret_var.datalen; q++) {
35117                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
35118                 int64_t ret_conv_16_ref = 0;
35119                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35120                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35121                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35122                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
35123                 if (ret_conv_16_var.is_owned) {
35124                         ret_conv_16_ref |= 1;
35125                 }
35126                 ret_arr_ptr[q] = ret_conv_16_ref;
35127         }
35128         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35129         FREE(ret_var.data);
35130         return ret_arr;
35131 }
35132
35133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35134         LDKCommitmentUpdate this_ptr_conv;
35135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35136         this_ptr_conv.is_owned = false;
35137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35138         LDKCVec_UpdateFailHTLCZ val_constr;
35139         val_constr.datalen = (*env)->GetArrayLength(env, val);
35140         if (val_constr.datalen > 0)
35141                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
35142         else
35143                 val_constr.data = NULL;
35144         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35145         for (size_t q = 0; q < val_constr.datalen; q++) {
35146                 int64_t val_conv_16 = val_vals[q];
35147                 LDKUpdateFailHTLC val_conv_16_conv;
35148                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
35149                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
35150                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
35151                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
35152                 val_constr.data[q] = val_conv_16_conv;
35153         }
35154         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35155         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
35156 }
35157
35158 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35159         LDKCommitmentUpdate this_ptr_conv;
35160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35161         this_ptr_conv.is_owned = false;
35162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35163         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
35164         int64_tArray ret_arr = NULL;
35165         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35166         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35167         for (size_t z = 0; z < ret_var.datalen; z++) {
35168                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
35169                 int64_t ret_conv_25_ref = 0;
35170                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35171                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35172                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
35173                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
35174                 if (ret_conv_25_var.is_owned) {
35175                         ret_conv_25_ref |= 1;
35176                 }
35177                 ret_arr_ptr[z] = ret_conv_25_ref;
35178         }
35179         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35180         FREE(ret_var.data);
35181         return ret_arr;
35182 }
35183
35184 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) {
35185         LDKCommitmentUpdate this_ptr_conv;
35186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35187         this_ptr_conv.is_owned = false;
35188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35189         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
35190         val_constr.datalen = (*env)->GetArrayLength(env, val);
35191         if (val_constr.datalen > 0)
35192                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
35193         else
35194                 val_constr.data = NULL;
35195         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35196         for (size_t z = 0; z < val_constr.datalen; z++) {
35197                 int64_t val_conv_25 = val_vals[z];
35198                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
35199                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
35200                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
35201                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
35202                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
35203                 val_constr.data[z] = val_conv_25_conv;
35204         }
35205         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35206         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
35207 }
35208
35209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
35210         LDKCommitmentUpdate this_ptr_conv;
35211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35212         this_ptr_conv.is_owned = false;
35213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35214         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
35215         int64_t ret_ref = 0;
35216         if ((uintptr_t)ret_var.inner > 4096) {
35217                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35218                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35220                 ret_ref = (uintptr_t)ret_var.inner;
35221                 if (ret_var.is_owned) {
35222                         ret_ref |= 1;
35223                 }
35224         }
35225         return ret_ref;
35226 }
35227
35228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35229         LDKCommitmentUpdate this_ptr_conv;
35230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35231         this_ptr_conv.is_owned = false;
35232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35233         LDKUpdateFee val_conv;
35234         val_conv.inner = (void*)(val & (~1));
35235         val_conv.is_owned = (val & 1) || (val == 0);
35236         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35237         val_conv = UpdateFee_clone(&val_conv);
35238         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
35239 }
35240
35241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
35242         LDKCommitmentUpdate this_ptr_conv;
35243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35244         this_ptr_conv.is_owned = false;
35245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35246         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
35247         int64_t ret_ref = 0;
35248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35251         ret_ref = (uintptr_t)ret_var.inner;
35252         if (ret_var.is_owned) {
35253                 ret_ref |= 1;
35254         }
35255         return ret_ref;
35256 }
35257
35258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35259         LDKCommitmentUpdate this_ptr_conv;
35260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35261         this_ptr_conv.is_owned = false;
35262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35263         LDKCommitmentSigned val_conv;
35264         val_conv.inner = (void*)(val & (~1));
35265         val_conv.is_owned = (val & 1) || (val == 0);
35266         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35267         val_conv = CommitmentSigned_clone(&val_conv);
35268         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
35269 }
35270
35271 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) {
35272         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
35273         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
35274         if (update_add_htlcs_arg_constr.datalen > 0)
35275                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
35276         else
35277                 update_add_htlcs_arg_constr.data = NULL;
35278         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
35279         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
35280                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
35281                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
35282                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
35283                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
35284                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
35285                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
35286                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
35287         }
35288         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
35289         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
35290         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
35291         if (update_fulfill_htlcs_arg_constr.datalen > 0)
35292                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
35293         else
35294                 update_fulfill_htlcs_arg_constr.data = NULL;
35295         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
35296         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
35297                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
35298                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
35299                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
35300                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
35301                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
35302                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
35303                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
35304         }
35305         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
35306         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
35307         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
35308         if (update_fail_htlcs_arg_constr.datalen > 0)
35309                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
35310         else
35311                 update_fail_htlcs_arg_constr.data = NULL;
35312         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
35313         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
35314                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
35315                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
35316                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
35317                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
35318                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
35319                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
35320                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
35321         }
35322         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
35323         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
35324         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
35325         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
35326                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
35327         else
35328                 update_fail_malformed_htlcs_arg_constr.data = NULL;
35329         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
35330         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
35331                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
35332                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
35333                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
35334                 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);
35335                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
35336                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
35337                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
35338         }
35339         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
35340         LDKUpdateFee update_fee_arg_conv;
35341         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
35342         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
35343         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
35344         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
35345         LDKCommitmentSigned commitment_signed_arg_conv;
35346         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
35347         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
35348         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
35349         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
35350         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);
35351         int64_t ret_ref = 0;
35352         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35353         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35355         ret_ref = (uintptr_t)ret_var.inner;
35356         if (ret_var.is_owned) {
35357                 ret_ref |= 1;
35358         }
35359         return ret_ref;
35360 }
35361
35362 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
35363         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
35364 int64_t ret_ref = 0;
35365 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35366 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35367 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35368 ret_ref = (uintptr_t)ret_var.inner;
35369 if (ret_var.is_owned) {
35370         ret_ref |= 1;
35371 }
35372         return ret_ref;
35373 }
35374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35375         LDKCommitmentUpdate arg_conv;
35376         arg_conv.inner = (void*)(arg & (~1));
35377         arg_conv.is_owned = false;
35378         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35379         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
35380         return ret_conv;
35381 }
35382
35383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35384         LDKCommitmentUpdate orig_conv;
35385         orig_conv.inner = (void*)(orig & (~1));
35386         orig_conv.is_owned = false;
35387         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35388         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
35389         int64_t ret_ref = 0;
35390         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35391         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35393         ret_ref = (uintptr_t)ret_var.inner;
35394         if (ret_var.is_owned) {
35395                 ret_ref |= 1;
35396         }
35397         return ret_ref;
35398 }
35399
35400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35401         if ((this_ptr & 1) != 0) return;
35402         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35403         CHECK_ACCESS(this_ptr_ptr);
35404         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
35405         FREE((void*)this_ptr);
35406         ChannelMessageHandler_free(this_ptr_conv);
35407 }
35408
35409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35410         if ((this_ptr & 1) != 0) return;
35411         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35412         CHECK_ACCESS(this_ptr_ptr);
35413         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
35414         FREE((void*)this_ptr);
35415         RoutingMessageHandler_free(this_ptr_conv);
35416 }
35417
35418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
35419         LDKAcceptChannel obj_conv;
35420         obj_conv.inner = (void*)(obj & (~1));
35421         obj_conv.is_owned = false;
35422         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35423         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
35424         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35425         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35426         CVec_u8Z_free(ret_var);
35427         return ret_arr;
35428 }
35429
35430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35431         LDKu8slice ser_ref;
35432         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35433         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35434         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
35435         *ret_conv = AcceptChannel_read(ser_ref);
35436         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35437         return (int64_t)ret_conv;
35438 }
35439
35440 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
35441         LDKAnnouncementSignatures obj_conv;
35442         obj_conv.inner = (void*)(obj & (~1));
35443         obj_conv.is_owned = false;
35444         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35445         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
35446         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35447         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35448         CVec_u8Z_free(ret_var);
35449         return ret_arr;
35450 }
35451
35452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35453         LDKu8slice ser_ref;
35454         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35455         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35456         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
35457         *ret_conv = AnnouncementSignatures_read(ser_ref);
35458         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35459         return (int64_t)ret_conv;
35460 }
35461
35462 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
35463         LDKChannelReestablish obj_conv;
35464         obj_conv.inner = (void*)(obj & (~1));
35465         obj_conv.is_owned = false;
35466         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35467         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
35468         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35469         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35470         CVec_u8Z_free(ret_var);
35471         return ret_arr;
35472 }
35473
35474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35475         LDKu8slice ser_ref;
35476         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35477         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35478         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
35479         *ret_conv = ChannelReestablish_read(ser_ref);
35480         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35481         return (int64_t)ret_conv;
35482 }
35483
35484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35485         LDKClosingSigned obj_conv;
35486         obj_conv.inner = (void*)(obj & (~1));
35487         obj_conv.is_owned = false;
35488         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35489         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
35490         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35491         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35492         CVec_u8Z_free(ret_var);
35493         return ret_arr;
35494 }
35495
35496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35497         LDKu8slice ser_ref;
35498         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35499         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35500         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
35501         *ret_conv = ClosingSigned_read(ser_ref);
35502         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35503         return (int64_t)ret_conv;
35504 }
35505
35506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
35507         LDKClosingSignedFeeRange obj_conv;
35508         obj_conv.inner = (void*)(obj & (~1));
35509         obj_conv.is_owned = false;
35510         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35511         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
35512         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35513         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35514         CVec_u8Z_free(ret_var);
35515         return ret_arr;
35516 }
35517
35518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35519         LDKu8slice ser_ref;
35520         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35521         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35522         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
35523         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
35524         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35525         return (int64_t)ret_conv;
35526 }
35527
35528 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35529         LDKCommitmentSigned obj_conv;
35530         obj_conv.inner = (void*)(obj & (~1));
35531         obj_conv.is_owned = false;
35532         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35533         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
35534         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35535         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35536         CVec_u8Z_free(ret_var);
35537         return ret_arr;
35538 }
35539
35540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35541         LDKu8slice ser_ref;
35542         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35543         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35544         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
35545         *ret_conv = CommitmentSigned_read(ser_ref);
35546         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35547         return (int64_t)ret_conv;
35548 }
35549
35550 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
35551         LDKFundingCreated obj_conv;
35552         obj_conv.inner = (void*)(obj & (~1));
35553         obj_conv.is_owned = false;
35554         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35555         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
35556         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35557         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35558         CVec_u8Z_free(ret_var);
35559         return ret_arr;
35560 }
35561
35562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35563         LDKu8slice ser_ref;
35564         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35565         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35566         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
35567         *ret_conv = FundingCreated_read(ser_ref);
35568         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35569         return (int64_t)ret_conv;
35570 }
35571
35572 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
35573         LDKFundingSigned obj_conv;
35574         obj_conv.inner = (void*)(obj & (~1));
35575         obj_conv.is_owned = false;
35576         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35577         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
35578         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35579         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35580         CVec_u8Z_free(ret_var);
35581         return ret_arr;
35582 }
35583
35584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35585         LDKu8slice ser_ref;
35586         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35587         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35588         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
35589         *ret_conv = FundingSigned_read(ser_ref);
35590         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35591         return (int64_t)ret_conv;
35592 }
35593
35594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
35595         LDKFundingLocked obj_conv;
35596         obj_conv.inner = (void*)(obj & (~1));
35597         obj_conv.is_owned = false;
35598         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35599         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
35600         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35601         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35602         CVec_u8Z_free(ret_var);
35603         return ret_arr;
35604 }
35605
35606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35607         LDKu8slice ser_ref;
35608         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35609         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35610         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
35611         *ret_conv = FundingLocked_read(ser_ref);
35612         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35613         return (int64_t)ret_conv;
35614 }
35615
35616 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
35617         LDKInit obj_conv;
35618         obj_conv.inner = (void*)(obj & (~1));
35619         obj_conv.is_owned = false;
35620         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35621         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
35622         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35623         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35624         CVec_u8Z_free(ret_var);
35625         return ret_arr;
35626 }
35627
35628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35629         LDKu8slice ser_ref;
35630         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35631         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35632         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
35633         *ret_conv = Init_read(ser_ref);
35634         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35635         return (int64_t)ret_conv;
35636 }
35637
35638 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
35639         LDKOpenChannel obj_conv;
35640         obj_conv.inner = (void*)(obj & (~1));
35641         obj_conv.is_owned = false;
35642         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35643         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
35644         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35645         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35646         CVec_u8Z_free(ret_var);
35647         return ret_arr;
35648 }
35649
35650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35651         LDKu8slice ser_ref;
35652         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35653         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35654         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
35655         *ret_conv = OpenChannel_read(ser_ref);
35656         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35657         return (int64_t)ret_conv;
35658 }
35659
35660 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
35661         LDKRevokeAndACK obj_conv;
35662         obj_conv.inner = (void*)(obj & (~1));
35663         obj_conv.is_owned = false;
35664         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35665         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
35666         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35667         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35668         CVec_u8Z_free(ret_var);
35669         return ret_arr;
35670 }
35671
35672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35673         LDKu8slice ser_ref;
35674         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35675         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35676         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
35677         *ret_conv = RevokeAndACK_read(ser_ref);
35678         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35679         return (int64_t)ret_conv;
35680 }
35681
35682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
35683         LDKShutdown obj_conv;
35684         obj_conv.inner = (void*)(obj & (~1));
35685         obj_conv.is_owned = false;
35686         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35687         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
35688         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35689         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35690         CVec_u8Z_free(ret_var);
35691         return ret_arr;
35692 }
35693
35694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35695         LDKu8slice ser_ref;
35696         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35697         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35698         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
35699         *ret_conv = Shutdown_read(ser_ref);
35700         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35701         return (int64_t)ret_conv;
35702 }
35703
35704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35705         LDKUpdateFailHTLC obj_conv;
35706         obj_conv.inner = (void*)(obj & (~1));
35707         obj_conv.is_owned = false;
35708         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35709         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
35710         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35711         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35712         CVec_u8Z_free(ret_var);
35713         return ret_arr;
35714 }
35715
35716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35717         LDKu8slice ser_ref;
35718         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35719         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35720         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
35721         *ret_conv = UpdateFailHTLC_read(ser_ref);
35722         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35723         return (int64_t)ret_conv;
35724 }
35725
35726 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35727         LDKUpdateFailMalformedHTLC obj_conv;
35728         obj_conv.inner = (void*)(obj & (~1));
35729         obj_conv.is_owned = false;
35730         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35731         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
35732         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35733         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35734         CVec_u8Z_free(ret_var);
35735         return ret_arr;
35736 }
35737
35738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35739         LDKu8slice ser_ref;
35740         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35741         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35742         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
35743         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
35744         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35745         return (int64_t)ret_conv;
35746 }
35747
35748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
35749         LDKUpdateFee obj_conv;
35750         obj_conv.inner = (void*)(obj & (~1));
35751         obj_conv.is_owned = false;
35752         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35753         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
35754         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35755         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35756         CVec_u8Z_free(ret_var);
35757         return ret_arr;
35758 }
35759
35760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35761         LDKu8slice ser_ref;
35762         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35763         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35764         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
35765         *ret_conv = UpdateFee_read(ser_ref);
35766         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35767         return (int64_t)ret_conv;
35768 }
35769
35770 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35771         LDKUpdateFulfillHTLC obj_conv;
35772         obj_conv.inner = (void*)(obj & (~1));
35773         obj_conv.is_owned = false;
35774         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35775         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
35776         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35777         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35778         CVec_u8Z_free(ret_var);
35779         return ret_arr;
35780 }
35781
35782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35783         LDKu8slice ser_ref;
35784         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35785         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35786         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
35787         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
35788         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35789         return (int64_t)ret_conv;
35790 }
35791
35792 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
35793         LDKUpdateAddHTLC obj_conv;
35794         obj_conv.inner = (void*)(obj & (~1));
35795         obj_conv.is_owned = false;
35796         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35797         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
35798         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35799         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35800         CVec_u8Z_free(ret_var);
35801         return ret_arr;
35802 }
35803
35804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35805         LDKu8slice ser_ref;
35806         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35807         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35808         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
35809         *ret_conv = UpdateAddHTLC_read(ser_ref);
35810         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35811         return (int64_t)ret_conv;
35812 }
35813
35814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
35815         LDKPing obj_conv;
35816         obj_conv.inner = (void*)(obj & (~1));
35817         obj_conv.is_owned = false;
35818         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35819         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
35820         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35821         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35822         CVec_u8Z_free(ret_var);
35823         return ret_arr;
35824 }
35825
35826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35827         LDKu8slice ser_ref;
35828         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35829         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35830         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
35831         *ret_conv = Ping_read(ser_ref);
35832         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35833         return (int64_t)ret_conv;
35834 }
35835
35836 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
35837         LDKPong obj_conv;
35838         obj_conv.inner = (void*)(obj & (~1));
35839         obj_conv.is_owned = false;
35840         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35841         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
35842         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35843         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35844         CVec_u8Z_free(ret_var);
35845         return ret_arr;
35846 }
35847
35848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35849         LDKu8slice ser_ref;
35850         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35851         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35852         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
35853         *ret_conv = Pong_read(ser_ref);
35854         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35855         return (int64_t)ret_conv;
35856 }
35857
35858 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35859         LDKUnsignedChannelAnnouncement obj_conv;
35860         obj_conv.inner = (void*)(obj & (~1));
35861         obj_conv.is_owned = false;
35862         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35863         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
35864         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35865         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35866         CVec_u8Z_free(ret_var);
35867         return ret_arr;
35868 }
35869
35870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35871         LDKu8slice ser_ref;
35872         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35873         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35874         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
35875         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
35876         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35877         return (int64_t)ret_conv;
35878 }
35879
35880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35881         LDKChannelAnnouncement obj_conv;
35882         obj_conv.inner = (void*)(obj & (~1));
35883         obj_conv.is_owned = false;
35884         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35885         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
35886         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35887         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35888         CVec_u8Z_free(ret_var);
35889         return ret_arr;
35890 }
35891
35892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35893         LDKu8slice ser_ref;
35894         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35895         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35896         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
35897         *ret_conv = ChannelAnnouncement_read(ser_ref);
35898         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35899         return (int64_t)ret_conv;
35900 }
35901
35902 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
35903         LDKUnsignedChannelUpdate obj_conv;
35904         obj_conv.inner = (void*)(obj & (~1));
35905         obj_conv.is_owned = false;
35906         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35907         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
35908         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35909         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35910         CVec_u8Z_free(ret_var);
35911         return ret_arr;
35912 }
35913
35914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35915         LDKu8slice ser_ref;
35916         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35917         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35918         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
35919         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
35920         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35921         return (int64_t)ret_conv;
35922 }
35923
35924 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
35925         LDKChannelUpdate obj_conv;
35926         obj_conv.inner = (void*)(obj & (~1));
35927         obj_conv.is_owned = false;
35928         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35929         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
35930         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35931         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35932         CVec_u8Z_free(ret_var);
35933         return ret_arr;
35934 }
35935
35936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35937         LDKu8slice ser_ref;
35938         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35939         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35940         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
35941         *ret_conv = ChannelUpdate_read(ser_ref);
35942         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35943         return (int64_t)ret_conv;
35944 }
35945
35946 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
35947         LDKErrorMessage obj_conv;
35948         obj_conv.inner = (void*)(obj & (~1));
35949         obj_conv.is_owned = false;
35950         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35951         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
35952         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35953         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35954         CVec_u8Z_free(ret_var);
35955         return ret_arr;
35956 }
35957
35958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35959         LDKu8slice ser_ref;
35960         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35961         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35962         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
35963         *ret_conv = ErrorMessage_read(ser_ref);
35964         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35965         return (int64_t)ret_conv;
35966 }
35967
35968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
35969         LDKWarningMessage obj_conv;
35970         obj_conv.inner = (void*)(obj & (~1));
35971         obj_conv.is_owned = false;
35972         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35973         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
35974         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35975         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35976         CVec_u8Z_free(ret_var);
35977         return ret_arr;
35978 }
35979
35980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35981         LDKu8slice ser_ref;
35982         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35983         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35984         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
35985         *ret_conv = WarningMessage_read(ser_ref);
35986         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35987         return (int64_t)ret_conv;
35988 }
35989
35990 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
35991         LDKUnsignedNodeAnnouncement obj_conv;
35992         obj_conv.inner = (void*)(obj & (~1));
35993         obj_conv.is_owned = false;
35994         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35995         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
35996         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35997         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35998         CVec_u8Z_free(ret_var);
35999         return ret_arr;
36000 }
36001
36002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36003         LDKu8slice ser_ref;
36004         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36005         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36006         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
36007         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
36008         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36009         return (int64_t)ret_conv;
36010 }
36011
36012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
36013         LDKNodeAnnouncement obj_conv;
36014         obj_conv.inner = (void*)(obj & (~1));
36015         obj_conv.is_owned = false;
36016         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36017         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
36018         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36019         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36020         CVec_u8Z_free(ret_var);
36021         return ret_arr;
36022 }
36023
36024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36025         LDKu8slice ser_ref;
36026         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36027         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36028         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
36029         *ret_conv = NodeAnnouncement_read(ser_ref);
36030         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36031         return (int64_t)ret_conv;
36032 }
36033
36034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36035         LDKu8slice ser_ref;
36036         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36037         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36038         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
36039         *ret_conv = QueryShortChannelIds_read(ser_ref);
36040         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36041         return (int64_t)ret_conv;
36042 }
36043
36044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
36045         LDKQueryShortChannelIds obj_conv;
36046         obj_conv.inner = (void*)(obj & (~1));
36047         obj_conv.is_owned = false;
36048         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36049         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
36050         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36051         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36052         CVec_u8Z_free(ret_var);
36053         return ret_arr;
36054 }
36055
36056 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
36057         LDKReplyShortChannelIdsEnd obj_conv;
36058         obj_conv.inner = (void*)(obj & (~1));
36059         obj_conv.is_owned = false;
36060         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36061         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
36062         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36063         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36064         CVec_u8Z_free(ret_var);
36065         return ret_arr;
36066 }
36067
36068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36069         LDKu8slice ser_ref;
36070         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36071         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36072         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
36073         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
36074         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36075         return (int64_t)ret_conv;
36076 }
36077
36078 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
36079         LDKQueryChannelRange this_arg_conv;
36080         this_arg_conv.inner = (void*)(this_arg & (~1));
36081         this_arg_conv.is_owned = false;
36082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36083         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
36084         return ret_conv;
36085 }
36086
36087 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36088         LDKQueryChannelRange obj_conv;
36089         obj_conv.inner = (void*)(obj & (~1));
36090         obj_conv.is_owned = false;
36091         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36092         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
36093         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36094         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36095         CVec_u8Z_free(ret_var);
36096         return ret_arr;
36097 }
36098
36099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36100         LDKu8slice ser_ref;
36101         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36102         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36103         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
36104         *ret_conv = QueryChannelRange_read(ser_ref);
36105         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36106         return (int64_t)ret_conv;
36107 }
36108
36109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36110         LDKu8slice ser_ref;
36111         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36112         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36113         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
36114         *ret_conv = ReplyChannelRange_read(ser_ref);
36115         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36116         return (int64_t)ret_conv;
36117 }
36118
36119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
36120         LDKReplyChannelRange obj_conv;
36121         obj_conv.inner = (void*)(obj & (~1));
36122         obj_conv.is_owned = false;
36123         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36124         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
36125         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36126         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36127         CVec_u8Z_free(ret_var);
36128         return ret_arr;
36129 }
36130
36131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
36132         LDKGossipTimestampFilter obj_conv;
36133         obj_conv.inner = (void*)(obj & (~1));
36134         obj_conv.is_owned = false;
36135         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36136         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
36137         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36138         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36139         CVec_u8Z_free(ret_var);
36140         return ret_arr;
36141 }
36142
36143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36144         LDKu8slice ser_ref;
36145         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36146         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36147         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
36148         *ret_conv = GossipTimestampFilter_read(ser_ref);
36149         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36150         return (int64_t)ret_conv;
36151 }
36152
36153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36154         if ((this_ptr & 1) != 0) return;
36155         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36156         CHECK_ACCESS(this_ptr_ptr);
36157         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
36158         FREE((void*)this_ptr);
36159         CustomMessageHandler_free(this_ptr_conv);
36160 }
36161
36162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36163         LDKIgnoringMessageHandler this_obj_conv;
36164         this_obj_conv.inner = (void*)(this_obj & (~1));
36165         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36167         IgnoringMessageHandler_free(this_obj_conv);
36168 }
36169
36170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
36171         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
36172         int64_t ret_ref = 0;
36173         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36174         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36176         ret_ref = (uintptr_t)ret_var.inner;
36177         if (ret_var.is_owned) {
36178                 ret_ref |= 1;
36179         }
36180         return ret_ref;
36181 }
36182
36183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
36184         LDKIgnoringMessageHandler this_arg_conv;
36185         this_arg_conv.inner = (void*)(this_arg & (~1));
36186         this_arg_conv.is_owned = false;
36187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36188         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36189         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
36190         return (int64_t)ret_ret;
36191 }
36192
36193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36194         LDKIgnoringMessageHandler this_arg_conv;
36195         this_arg_conv.inner = (void*)(this_arg & (~1));
36196         this_arg_conv.is_owned = false;
36197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36198         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
36199         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
36200         return (int64_t)ret_ret;
36201 }
36202
36203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
36204         LDKIgnoringMessageHandler this_arg_conv;
36205         this_arg_conv.inner = (void*)(this_arg & (~1));
36206         this_arg_conv.is_owned = false;
36207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36208         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
36209         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
36210         return (int64_t)ret_ret;
36211 }
36212
36213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36214         LDKIgnoringMessageHandler this_arg_conv;
36215         this_arg_conv.inner = (void*)(this_arg & (~1));
36216         this_arg_conv.is_owned = false;
36217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36218         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
36219         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
36220         return (int64_t)ret_ret;
36221 }
36222
36223 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36224         LDKErroringMessageHandler this_obj_conv;
36225         this_obj_conv.inner = (void*)(this_obj & (~1));
36226         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36228         ErroringMessageHandler_free(this_obj_conv);
36229 }
36230
36231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
36232         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
36233         int64_t ret_ref = 0;
36234         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36235         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36237         ret_ref = (uintptr_t)ret_var.inner;
36238         if (ret_var.is_owned) {
36239                 ret_ref |= 1;
36240         }
36241         return ret_ref;
36242 }
36243
36244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
36245         LDKErroringMessageHandler this_arg_conv;
36246         this_arg_conv.inner = (void*)(this_arg & (~1));
36247         this_arg_conv.is_owned = false;
36248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36249         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36250         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
36251         return (int64_t)ret_ret;
36252 }
36253
36254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
36255         LDKErroringMessageHandler this_arg_conv;
36256         this_arg_conv.inner = (void*)(this_arg & (~1));
36257         this_arg_conv.is_owned = false;
36258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36259         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
36260         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
36261         return (int64_t)ret_ret;
36262 }
36263
36264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36265         LDKMessageHandler this_obj_conv;
36266         this_obj_conv.inner = (void*)(this_obj & (~1));
36267         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36269         MessageHandler_free(this_obj_conv);
36270 }
36271
36272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
36273         LDKMessageHandler this_ptr_conv;
36274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36275         this_ptr_conv.is_owned = false;
36276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36277         // WARNING: This object doesn't live past this scope, needs clone!
36278         int64_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
36279         return ret_ret;
36280 }
36281
36282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36283         LDKMessageHandler this_ptr_conv;
36284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36285         this_ptr_conv.is_owned = false;
36286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36287         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36288         CHECK_ACCESS(val_ptr);
36289         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
36290         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
36291                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36292                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
36293         }
36294         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
36295 }
36296
36297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
36298         LDKMessageHandler this_ptr_conv;
36299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36300         this_ptr_conv.is_owned = false;
36301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36302         // WARNING: This object doesn't live past this scope, needs clone!
36303         int64_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
36304         return ret_ret;
36305 }
36306
36307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36308         LDKMessageHandler this_ptr_conv;
36309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36310         this_ptr_conv.is_owned = false;
36311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36312         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36313         CHECK_ACCESS(val_ptr);
36314         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
36315         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
36316                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36317                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
36318         }
36319         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
36320 }
36321
36322 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) {
36323         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
36324         CHECK_ACCESS(chan_handler_arg_ptr);
36325         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
36326         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
36327                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36328                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
36329         }
36330         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
36331         CHECK_ACCESS(route_handler_arg_ptr);
36332         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
36333         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
36334                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36335                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
36336         }
36337         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
36338         int64_t ret_ref = 0;
36339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36342         ret_ref = (uintptr_t)ret_var.inner;
36343         if (ret_var.is_owned) {
36344                 ret_ref |= 1;
36345         }
36346         return ret_ref;
36347 }
36348
36349 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
36350         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
36351         *ret_ret = SocketDescriptor_clone(arg);
36352         return (int64_t)ret_ret;
36353 }
36354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36355         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
36356         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
36357         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
36358         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
36359         return ret_conv;
36360 }
36361
36362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36363         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
36364         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
36365         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
36366         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
36367         *ret_ret = SocketDescriptor_clone(orig_conv);
36368         return (int64_t)ret_ret;
36369 }
36370
36371 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
36372         if ((this_ptr & 1) != 0) return;
36373         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36374         CHECK_ACCESS(this_ptr_ptr);
36375         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
36376         FREE((void*)this_ptr);
36377         SocketDescriptor_free(this_ptr_conv);
36378 }
36379
36380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36381         LDKPeerHandleError this_obj_conv;
36382         this_obj_conv.inner = (void*)(this_obj & (~1));
36383         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36385         PeerHandleError_free(this_obj_conv);
36386 }
36387
36388 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
36389         LDKPeerHandleError this_ptr_conv;
36390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36391         this_ptr_conv.is_owned = false;
36392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36393         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
36394         return ret_conv;
36395 }
36396
36397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36398         LDKPeerHandleError this_ptr_conv;
36399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36400         this_ptr_conv.is_owned = false;
36401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36402         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
36403 }
36404
36405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
36406         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
36407         int64_t ret_ref = 0;
36408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36411         ret_ref = (uintptr_t)ret_var.inner;
36412         if (ret_var.is_owned) {
36413                 ret_ref |= 1;
36414         }
36415         return ret_ref;
36416 }
36417
36418 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
36419         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
36420 int64_t ret_ref = 0;
36421 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36422 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36423 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36424 ret_ref = (uintptr_t)ret_var.inner;
36425 if (ret_var.is_owned) {
36426         ret_ref |= 1;
36427 }
36428         return ret_ref;
36429 }
36430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36431         LDKPeerHandleError arg_conv;
36432         arg_conv.inner = (void*)(arg & (~1));
36433         arg_conv.is_owned = false;
36434         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36435         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
36436         return ret_conv;
36437 }
36438
36439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36440         LDKPeerHandleError orig_conv;
36441         orig_conv.inner = (void*)(orig & (~1));
36442         orig_conv.is_owned = false;
36443         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36444         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
36445         int64_t ret_ref = 0;
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         return ret_ref;
36454 }
36455
36456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36457         LDKPeerManager this_obj_conv;
36458         this_obj_conv.inner = (void*)(this_obj & (~1));
36459         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36461         PeerManager_free(this_obj_conv);
36462 }
36463
36464 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) {
36465         LDKMessageHandler message_handler_conv;
36466         message_handler_conv.inner = (void*)(message_handler & (~1));
36467         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
36468         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
36469         // WARNING: we need a move here but no clone is available for LDKMessageHandler
36470         LDKSecretKey our_node_secret_ref;
36471         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
36472         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
36473         unsigned char ephemeral_random_data_arr[32];
36474         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
36475         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
36476         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
36477         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
36478         CHECK_ACCESS(logger_ptr);
36479         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
36480         if (logger_conv.free == LDKLogger_JCalls_free) {
36481                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36482                 LDKLogger_JCalls_cloned(&logger_conv);
36483         }
36484         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
36485         CHECK_ACCESS(custom_message_handler_ptr);
36486         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
36487         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
36488                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36489                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
36490         }
36491         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
36492         int64_t ret_ref = 0;
36493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36496         ret_ref = (uintptr_t)ret_var.inner;
36497         if (ret_var.is_owned) {
36498                 ret_ref |= 1;
36499         }
36500         return ret_ref;
36501 }
36502
36503 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
36504         LDKPeerManager this_arg_conv;
36505         this_arg_conv.inner = (void*)(this_arg & (~1));
36506         this_arg_conv.is_owned = false;
36507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36508         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
36509         jobjectArray ret_arr = NULL;
36510         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
36511         ;
36512         for (size_t i = 0; i < ret_var.datalen; i++) {
36513                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
36514                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
36515                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
36516         }
36517         
36518         FREE(ret_var.data);
36519         return ret_arr;
36520 }
36521
36522 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) {
36523         LDKPeerManager this_arg_conv;
36524         this_arg_conv.inner = (void*)(this_arg & (~1));
36525         this_arg_conv.is_owned = false;
36526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36527         LDKPublicKey their_node_id_ref;
36528         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
36529         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
36530         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36531         CHECK_ACCESS(descriptor_ptr);
36532         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
36533         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
36534                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36535                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
36536         }
36537         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
36538         CHECK_ACCESS(remote_network_address_ptr);
36539         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
36540         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
36541         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
36542         return (int64_t)ret_conv;
36543 }
36544
36545 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) {
36546         LDKPeerManager this_arg_conv;
36547         this_arg_conv.inner = (void*)(this_arg & (~1));
36548         this_arg_conv.is_owned = false;
36549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36550         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36551         CHECK_ACCESS(descriptor_ptr);
36552         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
36553         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
36554                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36555                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
36556         }
36557         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
36558         CHECK_ACCESS(remote_network_address_ptr);
36559         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
36560         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
36561         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
36562         return (int64_t)ret_conv;
36563 }
36564
36565 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) {
36566         LDKPeerManager this_arg_conv;
36567         this_arg_conv.inner = (void*)(this_arg & (~1));
36568         this_arg_conv.is_owned = false;
36569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36570         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36571         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
36572         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
36573         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
36574         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
36575         return (int64_t)ret_conv;
36576 }
36577
36578 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) {
36579         LDKPeerManager this_arg_conv;
36580         this_arg_conv.inner = (void*)(this_arg & (~1));
36581         this_arg_conv.is_owned = false;
36582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36583         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
36584         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
36585         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
36586         LDKu8slice data_ref;
36587         data_ref.datalen = (*env)->GetArrayLength(env, data);
36588         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
36589         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
36590         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
36591         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
36592         return (int64_t)ret_conv;
36593 }
36594
36595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
36596         LDKPeerManager this_arg_conv;
36597         this_arg_conv.inner = (void*)(this_arg & (~1));
36598         this_arg_conv.is_owned = false;
36599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36600         PeerManager_process_events(&this_arg_conv);
36601 }
36602
36603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
36604         LDKPeerManager this_arg_conv;
36605         this_arg_conv.inner = (void*)(this_arg & (~1));
36606         this_arg_conv.is_owned = false;
36607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36608         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
36609         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
36610         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
36611         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
36612 }
36613
36614 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) {
36615         LDKPeerManager this_arg_conv;
36616         this_arg_conv.inner = (void*)(this_arg & (~1));
36617         this_arg_conv.is_owned = false;
36618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36619         LDKPublicKey node_id_ref;
36620         CHECK((*env)->GetArrayLength(env, node_id) == 33);
36621         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
36622         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
36623 }
36624
36625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
36626         LDKPeerManager this_arg_conv;
36627         this_arg_conv.inner = (void*)(this_arg & (~1));
36628         this_arg_conv.is_owned = false;
36629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36630         PeerManager_disconnect_all_peers(&this_arg_conv);
36631 }
36632
36633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
36634         LDKPeerManager this_arg_conv;
36635         this_arg_conv.inner = (void*)(this_arg & (~1));
36636         this_arg_conv.is_owned = false;
36637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36638         PeerManager_timer_tick_occurred(&this_arg_conv);
36639 }
36640
36641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
36642         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
36643         return ret_conv;
36644 }
36645
36646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
36647         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
36648         return ret_conv;
36649 }
36650
36651 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
36652         unsigned char commitment_seed_arr[32];
36653         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
36654         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
36655         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
36656         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36657         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
36658         return ret_arr;
36659 }
36660
36661 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) {
36662         LDKCVec_u8Z to_holder_script_ref;
36663         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
36664         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
36665         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
36666         LDKCVec_u8Z to_counterparty_script_ref;
36667         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
36668         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
36669         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
36670         LDKOutPoint funding_outpoint_conv;
36671         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
36672         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
36673         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
36674         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
36675         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);
36676         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36677         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36678         Transaction_free(ret_var);
36679         return ret_arr;
36680 }
36681
36682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36683         LDKCounterpartyCommitmentSecrets this_obj_conv;
36684         this_obj_conv.inner = (void*)(this_obj & (~1));
36685         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36687         CounterpartyCommitmentSecrets_free(this_obj_conv);
36688 }
36689
36690 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
36691         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
36692 int64_t ret_ref = 0;
36693 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36694 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36695 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36696 ret_ref = (uintptr_t)ret_var.inner;
36697 if (ret_var.is_owned) {
36698         ret_ref |= 1;
36699 }
36700         return ret_ref;
36701 }
36702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36703         LDKCounterpartyCommitmentSecrets arg_conv;
36704         arg_conv.inner = (void*)(arg & (~1));
36705         arg_conv.is_owned = false;
36706         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36707         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
36708         return ret_conv;
36709 }
36710
36711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36712         LDKCounterpartyCommitmentSecrets orig_conv;
36713         orig_conv.inner = (void*)(orig & (~1));
36714         orig_conv.is_owned = false;
36715         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36716         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
36717         int64_t ret_ref = 0;
36718         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36719         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36721         ret_ref = (uintptr_t)ret_var.inner;
36722         if (ret_var.is_owned) {
36723                 ret_ref |= 1;
36724         }
36725         return ret_ref;
36726 }
36727
36728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
36729         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
36730         int64_t ret_ref = 0;
36731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36734         ret_ref = (uintptr_t)ret_var.inner;
36735         if (ret_var.is_owned) {
36736                 ret_ref |= 1;
36737         }
36738         return ret_ref;
36739 }
36740
36741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
36742         LDKCounterpartyCommitmentSecrets this_arg_conv;
36743         this_arg_conv.inner = (void*)(this_arg & (~1));
36744         this_arg_conv.is_owned = false;
36745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36746         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
36747         return ret_conv;
36748 }
36749
36750 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) {
36751         LDKCounterpartyCommitmentSecrets this_arg_conv;
36752         this_arg_conv.inner = (void*)(this_arg & (~1));
36753         this_arg_conv.is_owned = false;
36754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36755         LDKThirtyTwoBytes secret_ref;
36756         CHECK((*env)->GetArrayLength(env, secret) == 32);
36757         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
36758         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
36759         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
36760         return (int64_t)ret_conv;
36761 }
36762
36763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
36764         LDKCounterpartyCommitmentSecrets this_arg_conv;
36765         this_arg_conv.inner = (void*)(this_arg & (~1));
36766         this_arg_conv.is_owned = false;
36767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36768         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36769         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
36770         return ret_arr;
36771 }
36772
36773 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
36774         LDKCounterpartyCommitmentSecrets obj_conv;
36775         obj_conv.inner = (void*)(obj & (~1));
36776         obj_conv.is_owned = false;
36777         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36778         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
36779         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36780         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36781         CVec_u8Z_free(ret_var);
36782         return ret_arr;
36783 }
36784
36785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36786         LDKu8slice ser_ref;
36787         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36788         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36789         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
36790         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
36791         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36792         return (int64_t)ret_conv;
36793 }
36794
36795 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) {
36796         LDKPublicKey per_commitment_point_ref;
36797         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36798         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36799         unsigned char base_secret_arr[32];
36800         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
36801         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
36802         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
36803         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
36804         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
36805         return (int64_t)ret_conv;
36806 }
36807
36808 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) {
36809         LDKPublicKey per_commitment_point_ref;
36810         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36811         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36812         LDKPublicKey base_point_ref;
36813         CHECK((*env)->GetArrayLength(env, base_point) == 33);
36814         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
36815         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
36816         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
36817         return (int64_t)ret_conv;
36818 }
36819
36820 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) {
36821         unsigned char per_commitment_secret_arr[32];
36822         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
36823         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
36824         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
36825         unsigned char countersignatory_revocation_base_secret_arr[32];
36826         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
36827         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
36828         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
36829         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
36830         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
36831         return (int64_t)ret_conv;
36832 }
36833
36834 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) {
36835         LDKPublicKey per_commitment_point_ref;
36836         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
36837         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
36838         LDKPublicKey countersignatory_revocation_base_point_ref;
36839         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
36840         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
36841         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
36842         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
36843         return (int64_t)ret_conv;
36844 }
36845
36846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36847         LDKTxCreationKeys this_obj_conv;
36848         this_obj_conv.inner = (void*)(this_obj & (~1));
36849         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36851         TxCreationKeys_free(this_obj_conv);
36852 }
36853
36854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36855         LDKTxCreationKeys this_ptr_conv;
36856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36857         this_ptr_conv.is_owned = false;
36858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36859         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36860         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
36861         return ret_arr;
36862 }
36863
36864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36865         LDKTxCreationKeys this_ptr_conv;
36866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36867         this_ptr_conv.is_owned = false;
36868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36869         LDKPublicKey val_ref;
36870         CHECK((*env)->GetArrayLength(env, val) == 33);
36871         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36872         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
36873 }
36874
36875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36876         LDKTxCreationKeys this_ptr_conv;
36877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36878         this_ptr_conv.is_owned = false;
36879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36880         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36881         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
36882         return ret_arr;
36883 }
36884
36885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36886         LDKTxCreationKeys this_ptr_conv;
36887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36888         this_ptr_conv.is_owned = false;
36889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36890         LDKPublicKey val_ref;
36891         CHECK((*env)->GetArrayLength(env, val) == 33);
36892         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36893         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
36894 }
36895
36896 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36897         LDKTxCreationKeys this_ptr_conv;
36898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36899         this_ptr_conv.is_owned = false;
36900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36901         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36902         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
36903         return ret_arr;
36904 }
36905
36906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36907         LDKTxCreationKeys this_ptr_conv;
36908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36909         this_ptr_conv.is_owned = false;
36910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36911         LDKPublicKey val_ref;
36912         CHECK((*env)->GetArrayLength(env, val) == 33);
36913         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36914         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
36915 }
36916
36917 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36918         LDKTxCreationKeys this_ptr_conv;
36919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36920         this_ptr_conv.is_owned = false;
36921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36922         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36923         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
36924         return ret_arr;
36925 }
36926
36927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36928         LDKTxCreationKeys this_ptr_conv;
36929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36930         this_ptr_conv.is_owned = false;
36931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36932         LDKPublicKey val_ref;
36933         CHECK((*env)->GetArrayLength(env, val) == 33);
36934         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36935         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
36936 }
36937
36938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
36939         LDKTxCreationKeys this_ptr_conv;
36940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36941         this_ptr_conv.is_owned = false;
36942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36943         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36944         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
36945         return ret_arr;
36946 }
36947
36948 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) {
36949         LDKTxCreationKeys this_ptr_conv;
36950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36951         this_ptr_conv.is_owned = false;
36952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36953         LDKPublicKey val_ref;
36954         CHECK((*env)->GetArrayLength(env, val) == 33);
36955         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36956         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
36957 }
36958
36959 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) {
36960         LDKPublicKey per_commitment_point_arg_ref;
36961         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
36962         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
36963         LDKPublicKey revocation_key_arg_ref;
36964         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
36965         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
36966         LDKPublicKey broadcaster_htlc_key_arg_ref;
36967         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
36968         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
36969         LDKPublicKey countersignatory_htlc_key_arg_ref;
36970         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
36971         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
36972         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
36973         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
36974         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
36975         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);
36976         int64_t ret_ref = 0;
36977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36980         ret_ref = (uintptr_t)ret_var.inner;
36981         if (ret_var.is_owned) {
36982                 ret_ref |= 1;
36983         }
36984         return ret_ref;
36985 }
36986
36987 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
36988         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
36989 int64_t ret_ref = 0;
36990 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36991 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36992 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36993 ret_ref = (uintptr_t)ret_var.inner;
36994 if (ret_var.is_owned) {
36995         ret_ref |= 1;
36996 }
36997         return ret_ref;
36998 }
36999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37000         LDKTxCreationKeys arg_conv;
37001         arg_conv.inner = (void*)(arg & (~1));
37002         arg_conv.is_owned = false;
37003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37004         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
37005         return ret_conv;
37006 }
37007
37008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37009         LDKTxCreationKeys orig_conv;
37010         orig_conv.inner = (void*)(orig & (~1));
37011         orig_conv.is_owned = false;
37012         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37013         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
37014         int64_t ret_ref = 0;
37015         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37016         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37018         ret_ref = (uintptr_t)ret_var.inner;
37019         if (ret_var.is_owned) {
37020                 ret_ref |= 1;
37021         }
37022         return ret_ref;
37023 }
37024
37025 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
37026         LDKTxCreationKeys obj_conv;
37027         obj_conv.inner = (void*)(obj & (~1));
37028         obj_conv.is_owned = false;
37029         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37030         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
37031         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37032         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37033         CVec_u8Z_free(ret_var);
37034         return ret_arr;
37035 }
37036
37037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37038         LDKu8slice ser_ref;
37039         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37040         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37041         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
37042         *ret_conv = TxCreationKeys_read(ser_ref);
37043         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37044         return (int64_t)ret_conv;
37045 }
37046
37047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37048         LDKChannelPublicKeys this_obj_conv;
37049         this_obj_conv.inner = (void*)(this_obj & (~1));
37050         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37052         ChannelPublicKeys_free(this_obj_conv);
37053 }
37054
37055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
37056         LDKChannelPublicKeys this_ptr_conv;
37057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37058         this_ptr_conv.is_owned = false;
37059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37060         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37061         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
37062         return ret_arr;
37063 }
37064
37065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37066         LDKChannelPublicKeys this_ptr_conv;
37067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37068         this_ptr_conv.is_owned = false;
37069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37070         LDKPublicKey val_ref;
37071         CHECK((*env)->GetArrayLength(env, val) == 33);
37072         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37073         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
37074 }
37075
37076 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37077         LDKChannelPublicKeys this_ptr_conv;
37078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37079         this_ptr_conv.is_owned = false;
37080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37081         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37082         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
37083         return ret_arr;
37084 }
37085
37086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37087         LDKChannelPublicKeys this_ptr_conv;
37088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37089         this_ptr_conv.is_owned = false;
37090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37091         LDKPublicKey val_ref;
37092         CHECK((*env)->GetArrayLength(env, val) == 33);
37093         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37094         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
37095 }
37096
37097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37098         LDKChannelPublicKeys this_ptr_conv;
37099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37100         this_ptr_conv.is_owned = false;
37101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37102         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37103         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
37104         return ret_arr;
37105 }
37106
37107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37108         LDKChannelPublicKeys this_ptr_conv;
37109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37110         this_ptr_conv.is_owned = false;
37111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37112         LDKPublicKey val_ref;
37113         CHECK((*env)->GetArrayLength(env, val) == 33);
37114         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37115         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
37116 }
37117
37118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37119         LDKChannelPublicKeys this_ptr_conv;
37120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37121         this_ptr_conv.is_owned = false;
37122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37123         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37124         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
37125         return ret_arr;
37126 }
37127
37128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37129         LDKChannelPublicKeys this_ptr_conv;
37130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37131         this_ptr_conv.is_owned = false;
37132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37133         LDKPublicKey val_ref;
37134         CHECK((*env)->GetArrayLength(env, val) == 33);
37135         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37136         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
37137 }
37138
37139 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37140         LDKChannelPublicKeys this_ptr_conv;
37141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37142         this_ptr_conv.is_owned = false;
37143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37144         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37145         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
37146         return ret_arr;
37147 }
37148
37149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37150         LDKChannelPublicKeys this_ptr_conv;
37151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37152         this_ptr_conv.is_owned = false;
37153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37154         LDKPublicKey val_ref;
37155         CHECK((*env)->GetArrayLength(env, val) == 33);
37156         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37157         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
37158 }
37159
37160 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) {
37161         LDKPublicKey funding_pubkey_arg_ref;
37162         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
37163         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
37164         LDKPublicKey revocation_basepoint_arg_ref;
37165         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
37166         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
37167         LDKPublicKey payment_point_arg_ref;
37168         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
37169         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
37170         LDKPublicKey delayed_payment_basepoint_arg_ref;
37171         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
37172         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
37173         LDKPublicKey htlc_basepoint_arg_ref;
37174         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
37175         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
37176         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);
37177         int64_t ret_ref = 0;
37178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37181         ret_ref = (uintptr_t)ret_var.inner;
37182         if (ret_var.is_owned) {
37183                 ret_ref |= 1;
37184         }
37185         return ret_ref;
37186 }
37187
37188 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
37189         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
37190 int64_t ret_ref = 0;
37191 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37192 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37193 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37194 ret_ref = (uintptr_t)ret_var.inner;
37195 if (ret_var.is_owned) {
37196         ret_ref |= 1;
37197 }
37198         return ret_ref;
37199 }
37200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37201         LDKChannelPublicKeys arg_conv;
37202         arg_conv.inner = (void*)(arg & (~1));
37203         arg_conv.is_owned = false;
37204         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37205         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
37206         return ret_conv;
37207 }
37208
37209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37210         LDKChannelPublicKeys orig_conv;
37211         orig_conv.inner = (void*)(orig & (~1));
37212         orig_conv.is_owned = false;
37213         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37214         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
37215         int64_t ret_ref = 0;
37216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37219         ret_ref = (uintptr_t)ret_var.inner;
37220         if (ret_var.is_owned) {
37221                 ret_ref |= 1;
37222         }
37223         return ret_ref;
37224 }
37225
37226 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
37227         LDKChannelPublicKeys obj_conv;
37228         obj_conv.inner = (void*)(obj & (~1));
37229         obj_conv.is_owned = false;
37230         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37231         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
37232         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37233         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37234         CVec_u8Z_free(ret_var);
37235         return ret_arr;
37236 }
37237
37238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37239         LDKu8slice ser_ref;
37240         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37241         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37242         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
37243         *ret_conv = ChannelPublicKeys_read(ser_ref);
37244         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37245         return (int64_t)ret_conv;
37246 }
37247
37248 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) {
37249         LDKPublicKey per_commitment_point_ref;
37250         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37251         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37252         LDKPublicKey broadcaster_delayed_payment_base_ref;
37253         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
37254         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
37255         LDKPublicKey broadcaster_htlc_base_ref;
37256         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
37257         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
37258         LDKPublicKey countersignatory_revocation_base_ref;
37259         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
37260         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
37261         LDKPublicKey countersignatory_htlc_base_ref;
37262         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
37263         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
37264         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
37265         *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);
37266         return (int64_t)ret_conv;
37267 }
37268
37269 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) {
37270         LDKPublicKey per_commitment_point_ref;
37271         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
37272         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
37273         LDKChannelPublicKeys broadcaster_keys_conv;
37274         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
37275         broadcaster_keys_conv.is_owned = false;
37276         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
37277         LDKChannelPublicKeys countersignatory_keys_conv;
37278         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
37279         countersignatory_keys_conv.is_owned = false;
37280         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
37281         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
37282         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
37283         return (int64_t)ret_conv;
37284 }
37285
37286 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) {
37287         LDKPublicKey revocation_key_ref;
37288         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
37289         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
37290         LDKPublicKey broadcaster_delayed_payment_key_ref;
37291         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
37292         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
37293         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
37294         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37295         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37296         CVec_u8Z_free(ret_var);
37297         return ret_arr;
37298 }
37299
37300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37301         LDKHTLCOutputInCommitment this_obj_conv;
37302         this_obj_conv.inner = (void*)(this_obj & (~1));
37303         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37305         HTLCOutputInCommitment_free(this_obj_conv);
37306 }
37307
37308 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
37309         LDKHTLCOutputInCommitment this_ptr_conv;
37310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37311         this_ptr_conv.is_owned = false;
37312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37313         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
37314         return ret_conv;
37315 }
37316
37317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37318         LDKHTLCOutputInCommitment this_ptr_conv;
37319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37320         this_ptr_conv.is_owned = false;
37321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37322         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
37323 }
37324
37325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37326         LDKHTLCOutputInCommitment this_ptr_conv;
37327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37328         this_ptr_conv.is_owned = false;
37329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37330         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
37331         return ret_conv;
37332 }
37333
37334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37335         LDKHTLCOutputInCommitment this_ptr_conv;
37336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37337         this_ptr_conv.is_owned = false;
37338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37339         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
37340 }
37341
37342 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
37343         LDKHTLCOutputInCommitment this_ptr_conv;
37344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37345         this_ptr_conv.is_owned = false;
37346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37347         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
37348         return ret_conv;
37349 }
37350
37351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37352         LDKHTLCOutputInCommitment this_ptr_conv;
37353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37354         this_ptr_conv.is_owned = false;
37355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37356         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
37357 }
37358
37359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37360         LDKHTLCOutputInCommitment this_ptr_conv;
37361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37362         this_ptr_conv.is_owned = false;
37363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37364         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37365         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
37366         return ret_arr;
37367 }
37368
37369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37370         LDKHTLCOutputInCommitment this_ptr_conv;
37371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37372         this_ptr_conv.is_owned = false;
37373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37374         LDKThirtyTwoBytes val_ref;
37375         CHECK((*env)->GetArrayLength(env, val) == 32);
37376         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37377         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
37378 }
37379
37380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
37381         LDKHTLCOutputInCommitment this_ptr_conv;
37382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37383         this_ptr_conv.is_owned = false;
37384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37385         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
37386         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
37387         int64_t ret_ref = (uintptr_t)ret_copy;
37388         return ret_ref;
37389 }
37390
37391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37392         LDKHTLCOutputInCommitment this_ptr_conv;
37393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37394         this_ptr_conv.is_owned = false;
37395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37396         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
37397         CHECK_ACCESS(val_ptr);
37398         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
37399         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
37400         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
37401 }
37402
37403 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) {
37404         LDKThirtyTwoBytes payment_hash_arg_ref;
37405         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
37406         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
37407         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
37408         CHECK_ACCESS(transaction_output_index_arg_ptr);
37409         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
37410         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
37411         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
37412         int64_t ret_ref = 0;
37413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37416         ret_ref = (uintptr_t)ret_var.inner;
37417         if (ret_var.is_owned) {
37418                 ret_ref |= 1;
37419         }
37420         return ret_ref;
37421 }
37422
37423 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
37424         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
37425 int64_t ret_ref = 0;
37426 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37427 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37428 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37429 ret_ref = (uintptr_t)ret_var.inner;
37430 if (ret_var.is_owned) {
37431         ret_ref |= 1;
37432 }
37433         return ret_ref;
37434 }
37435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37436         LDKHTLCOutputInCommitment arg_conv;
37437         arg_conv.inner = (void*)(arg & (~1));
37438         arg_conv.is_owned = false;
37439         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37440         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
37441         return ret_conv;
37442 }
37443
37444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37445         LDKHTLCOutputInCommitment orig_conv;
37446         orig_conv.inner = (void*)(orig & (~1));
37447         orig_conv.is_owned = false;
37448         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37449         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
37450         int64_t ret_ref = 0;
37451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37454         ret_ref = (uintptr_t)ret_var.inner;
37455         if (ret_var.is_owned) {
37456                 ret_ref |= 1;
37457         }
37458         return ret_ref;
37459 }
37460
37461 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
37462         LDKHTLCOutputInCommitment obj_conv;
37463         obj_conv.inner = (void*)(obj & (~1));
37464         obj_conv.is_owned = false;
37465         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37466         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
37467         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37468         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37469         CVec_u8Z_free(ret_var);
37470         return ret_arr;
37471 }
37472
37473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37474         LDKu8slice ser_ref;
37475         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37476         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37477         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
37478         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
37479         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37480         return (int64_t)ret_conv;
37481 }
37482
37483 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) {
37484         LDKHTLCOutputInCommitment htlc_conv;
37485         htlc_conv.inner = (void*)(htlc & (~1));
37486         htlc_conv.is_owned = false;
37487         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
37488         LDKTxCreationKeys keys_conv;
37489         keys_conv.inner = (void*)(keys & (~1));
37490         keys_conv.is_owned = false;
37491         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
37492         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
37493         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37494         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37495         CVec_u8Z_free(ret_var);
37496         return ret_arr;
37497 }
37498
37499 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
37500         LDKPublicKey broadcaster_ref;
37501         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
37502         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
37503         LDKPublicKey countersignatory_ref;
37504         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
37505         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
37506         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
37507         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37508         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37509         CVec_u8Z_free(ret_var);
37510         return ret_arr;
37511 }
37512
37513 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) {
37514         unsigned char commitment_txid_arr[32];
37515         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
37516         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
37517         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
37518         LDKHTLCOutputInCommitment htlc_conv;
37519         htlc_conv.inner = (void*)(htlc & (~1));
37520         htlc_conv.is_owned = false;
37521         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
37522         LDKPublicKey broadcaster_delayed_payment_key_ref;
37523         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
37524         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
37525         LDKPublicKey revocation_key_ref;
37526         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
37527         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
37528         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);
37529         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37530         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37531         Transaction_free(ret_var);
37532         return ret_arr;
37533 }
37534
37535 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
37536         LDKPublicKey funding_pubkey_ref;
37537         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
37538         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
37539         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
37540         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37541         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37542         CVec_u8Z_free(ret_var);
37543         return ret_arr;
37544 }
37545
37546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37547         LDKChannelTransactionParameters this_obj_conv;
37548         this_obj_conv.inner = (void*)(this_obj & (~1));
37549         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37551         ChannelTransactionParameters_free(this_obj_conv);
37552 }
37553
37554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
37555         LDKChannelTransactionParameters this_ptr_conv;
37556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37557         this_ptr_conv.is_owned = false;
37558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37559         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
37560         int64_t ret_ref = 0;
37561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37564         ret_ref = (uintptr_t)ret_var.inner;
37565         if (ret_var.is_owned) {
37566                 ret_ref |= 1;
37567         }
37568         return ret_ref;
37569 }
37570
37571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37572         LDKChannelTransactionParameters this_ptr_conv;
37573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37574         this_ptr_conv.is_owned = false;
37575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37576         LDKChannelPublicKeys val_conv;
37577         val_conv.inner = (void*)(val & (~1));
37578         val_conv.is_owned = (val & 1) || (val == 0);
37579         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37580         val_conv = ChannelPublicKeys_clone(&val_conv);
37581         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
37582 }
37583
37584 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
37585         LDKChannelTransactionParameters this_ptr_conv;
37586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37587         this_ptr_conv.is_owned = false;
37588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37589         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
37590         return ret_conv;
37591 }
37592
37593 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) {
37594         LDKChannelTransactionParameters this_ptr_conv;
37595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37596         this_ptr_conv.is_owned = false;
37597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37598         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
37599 }
37600
37601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
37602         LDKChannelTransactionParameters this_ptr_conv;
37603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37604         this_ptr_conv.is_owned = false;
37605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37606         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
37607         return ret_conv;
37608 }
37609
37610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37611         LDKChannelTransactionParameters this_ptr_conv;
37612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37613         this_ptr_conv.is_owned = false;
37614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37615         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
37616 }
37617
37618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
37619         LDKChannelTransactionParameters this_ptr_conv;
37620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37621         this_ptr_conv.is_owned = false;
37622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37623         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
37624         int64_t ret_ref = 0;
37625         if ((uintptr_t)ret_var.inner > 4096) {
37626                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37627                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37629                 ret_ref = (uintptr_t)ret_var.inner;
37630                 if (ret_var.is_owned) {
37631                         ret_ref |= 1;
37632                 }
37633         }
37634         return ret_ref;
37635 }
37636
37637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37638         LDKChannelTransactionParameters this_ptr_conv;
37639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37640         this_ptr_conv.is_owned = false;
37641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37642         LDKCounterpartyChannelTransactionParameters val_conv;
37643         val_conv.inner = (void*)(val & (~1));
37644         val_conv.is_owned = (val & 1) || (val == 0);
37645         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37646         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
37647         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
37648 }
37649
37650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
37651         LDKChannelTransactionParameters this_ptr_conv;
37652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37653         this_ptr_conv.is_owned = false;
37654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37655         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
37656         int64_t ret_ref = 0;
37657         if ((uintptr_t)ret_var.inner > 4096) {
37658                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37659                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37661                 ret_ref = (uintptr_t)ret_var.inner;
37662                 if (ret_var.is_owned) {
37663                         ret_ref |= 1;
37664                 }
37665         }
37666         return ret_ref;
37667 }
37668
37669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37670         LDKChannelTransactionParameters this_ptr_conv;
37671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37672         this_ptr_conv.is_owned = false;
37673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37674         LDKOutPoint val_conv;
37675         val_conv.inner = (void*)(val & (~1));
37676         val_conv.is_owned = (val & 1) || (val == 0);
37677         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37678         val_conv = OutPoint_clone(&val_conv);
37679         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
37680 }
37681
37682 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
37683         LDKChannelTransactionParameters this_ptr_conv;
37684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37685         this_ptr_conv.is_owned = false;
37686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37687         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
37688         return ret_conv;
37689 }
37690
37691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
37692         LDKChannelTransactionParameters this_ptr_conv;
37693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37694         this_ptr_conv.is_owned = false;
37695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37696         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
37697         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
37698 }
37699
37700 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) {
37701         LDKChannelPublicKeys holder_pubkeys_arg_conv;
37702         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
37703         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
37704         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
37705         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
37706         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
37707         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
37708         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
37709         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
37710         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
37711         LDKOutPoint funding_outpoint_arg_conv;
37712         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
37713         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
37714         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
37715         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
37716         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
37717         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);
37718         int64_t ret_ref = 0;
37719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37722         ret_ref = (uintptr_t)ret_var.inner;
37723         if (ret_var.is_owned) {
37724                 ret_ref |= 1;
37725         }
37726         return ret_ref;
37727 }
37728
37729 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
37730         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
37731 int64_t ret_ref = 0;
37732 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37733 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37734 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37735 ret_ref = (uintptr_t)ret_var.inner;
37736 if (ret_var.is_owned) {
37737         ret_ref |= 1;
37738 }
37739         return ret_ref;
37740 }
37741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37742         LDKChannelTransactionParameters arg_conv;
37743         arg_conv.inner = (void*)(arg & (~1));
37744         arg_conv.is_owned = false;
37745         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37746         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
37747         return ret_conv;
37748 }
37749
37750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37751         LDKChannelTransactionParameters orig_conv;
37752         orig_conv.inner = (void*)(orig & (~1));
37753         orig_conv.is_owned = false;
37754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37755         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
37756         int64_t ret_ref = 0;
37757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37760         ret_ref = (uintptr_t)ret_var.inner;
37761         if (ret_var.is_owned) {
37762                 ret_ref |= 1;
37763         }
37764         return ret_ref;
37765 }
37766
37767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37768         LDKCounterpartyChannelTransactionParameters this_obj_conv;
37769         this_obj_conv.inner = (void*)(this_obj & (~1));
37770         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37772         CounterpartyChannelTransactionParameters_free(this_obj_conv);
37773 }
37774
37775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
37776         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37778         this_ptr_conv.is_owned = false;
37779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37780         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
37781         int64_t ret_ref = 0;
37782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37785         ret_ref = (uintptr_t)ret_var.inner;
37786         if (ret_var.is_owned) {
37787                 ret_ref |= 1;
37788         }
37789         return ret_ref;
37790 }
37791
37792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37793         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37795         this_ptr_conv.is_owned = false;
37796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37797         LDKChannelPublicKeys val_conv;
37798         val_conv.inner = (void*)(val & (~1));
37799         val_conv.is_owned = (val & 1) || (val == 0);
37800         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37801         val_conv = ChannelPublicKeys_clone(&val_conv);
37802         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
37803 }
37804
37805 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
37806         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37808         this_ptr_conv.is_owned = false;
37809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37810         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
37811         return ret_conv;
37812 }
37813
37814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37815         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
37816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37817         this_ptr_conv.is_owned = false;
37818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37819         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
37820 }
37821
37822 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) {
37823         LDKChannelPublicKeys pubkeys_arg_conv;
37824         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
37825         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
37826         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
37827         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
37828         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
37829         int64_t ret_ref = 0;
37830         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37831         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37833         ret_ref = (uintptr_t)ret_var.inner;
37834         if (ret_var.is_owned) {
37835                 ret_ref |= 1;
37836         }
37837         return ret_ref;
37838 }
37839
37840 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
37841         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
37842 int64_t ret_ref = 0;
37843 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37844 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37845 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37846 ret_ref = (uintptr_t)ret_var.inner;
37847 if (ret_var.is_owned) {
37848         ret_ref |= 1;
37849 }
37850         return ret_ref;
37851 }
37852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37853         LDKCounterpartyChannelTransactionParameters arg_conv;
37854         arg_conv.inner = (void*)(arg & (~1));
37855         arg_conv.is_owned = false;
37856         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37857         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
37858         return ret_conv;
37859 }
37860
37861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37862         LDKCounterpartyChannelTransactionParameters orig_conv;
37863         orig_conv.inner = (void*)(orig & (~1));
37864         orig_conv.is_owned = false;
37865         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37866         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
37867         int64_t ret_ref = 0;
37868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37871         ret_ref = (uintptr_t)ret_var.inner;
37872         if (ret_var.is_owned) {
37873                 ret_ref |= 1;
37874         }
37875         return ret_ref;
37876 }
37877
37878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
37879         LDKChannelTransactionParameters this_arg_conv;
37880         this_arg_conv.inner = (void*)(this_arg & (~1));
37881         this_arg_conv.is_owned = false;
37882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37883         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
37884         return ret_conv;
37885 }
37886
37887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
37888         LDKChannelTransactionParameters this_arg_conv;
37889         this_arg_conv.inner = (void*)(this_arg & (~1));
37890         this_arg_conv.is_owned = false;
37891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37892         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
37893         int64_t ret_ref = 0;
37894         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37895         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37897         ret_ref = (uintptr_t)ret_var.inner;
37898         if (ret_var.is_owned) {
37899                 ret_ref |= 1;
37900         }
37901         return ret_ref;
37902 }
37903
37904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
37905         LDKChannelTransactionParameters this_arg_conv;
37906         this_arg_conv.inner = (void*)(this_arg & (~1));
37907         this_arg_conv.is_owned = false;
37908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37909         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
37910         int64_t ret_ref = 0;
37911         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37912         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37914         ret_ref = (uintptr_t)ret_var.inner;
37915         if (ret_var.is_owned) {
37916                 ret_ref |= 1;
37917         }
37918         return ret_ref;
37919 }
37920
37921 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37922         LDKCounterpartyChannelTransactionParameters obj_conv;
37923         obj_conv.inner = (void*)(obj & (~1));
37924         obj_conv.is_owned = false;
37925         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37926         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
37927         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37928         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37929         CVec_u8Z_free(ret_var);
37930         return ret_arr;
37931 }
37932
37933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37934         LDKu8slice ser_ref;
37935         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37936         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37937         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
37938         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
37939         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37940         return (int64_t)ret_conv;
37941 }
37942
37943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37944         LDKChannelTransactionParameters obj_conv;
37945         obj_conv.inner = (void*)(obj & (~1));
37946         obj_conv.is_owned = false;
37947         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37948         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
37949         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37950         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37951         CVec_u8Z_free(ret_var);
37952         return ret_arr;
37953 }
37954
37955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37956         LDKu8slice ser_ref;
37957         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37958         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37959         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
37960         *ret_conv = ChannelTransactionParameters_read(ser_ref);
37961         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37962         return (int64_t)ret_conv;
37963 }
37964
37965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37966         LDKDirectedChannelTransactionParameters this_obj_conv;
37967         this_obj_conv.inner = (void*)(this_obj & (~1));
37968         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37970         DirectedChannelTransactionParameters_free(this_obj_conv);
37971 }
37972
37973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
37974         LDKDirectedChannelTransactionParameters this_arg_conv;
37975         this_arg_conv.inner = (void*)(this_arg & (~1));
37976         this_arg_conv.is_owned = false;
37977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37978         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
37979         int64_t ret_ref = 0;
37980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37983         ret_ref = (uintptr_t)ret_var.inner;
37984         if (ret_var.is_owned) {
37985                 ret_ref |= 1;
37986         }
37987         return ret_ref;
37988 }
37989
37990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
37991         LDKDirectedChannelTransactionParameters this_arg_conv;
37992         this_arg_conv.inner = (void*)(this_arg & (~1));
37993         this_arg_conv.is_owned = false;
37994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37995         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
37996         int64_t ret_ref = 0;
37997         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37998         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38000         ret_ref = (uintptr_t)ret_var.inner;
38001         if (ret_var.is_owned) {
38002                 ret_ref |= 1;
38003         }
38004         return ret_ref;
38005 }
38006
38007 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
38008         LDKDirectedChannelTransactionParameters this_arg_conv;
38009         this_arg_conv.inner = (void*)(this_arg & (~1));
38010         this_arg_conv.is_owned = false;
38011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38012         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
38013         return ret_conv;
38014 }
38015
38016 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
38017         LDKDirectedChannelTransactionParameters this_arg_conv;
38018         this_arg_conv.inner = (void*)(this_arg & (~1));
38019         this_arg_conv.is_owned = false;
38020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38021         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
38022         return ret_conv;
38023 }
38024
38025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
38026         LDKDirectedChannelTransactionParameters this_arg_conv;
38027         this_arg_conv.inner = (void*)(this_arg & (~1));
38028         this_arg_conv.is_owned = false;
38029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38030         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
38031         int64_t ret_ref = 0;
38032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38035         ret_ref = (uintptr_t)ret_var.inner;
38036         if (ret_var.is_owned) {
38037                 ret_ref |= 1;
38038         }
38039         return ret_ref;
38040 }
38041
38042 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
38043         LDKDirectedChannelTransactionParameters this_arg_conv;
38044         this_arg_conv.inner = (void*)(this_arg & (~1));
38045         this_arg_conv.is_owned = false;
38046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38047         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
38048         return ret_conv;
38049 }
38050
38051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38052         LDKHolderCommitmentTransaction this_obj_conv;
38053         this_obj_conv.inner = (void*)(this_obj & (~1));
38054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38056         HolderCommitmentTransaction_free(this_obj_conv);
38057 }
38058
38059 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
38060         LDKHolderCommitmentTransaction this_ptr_conv;
38061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38062         this_ptr_conv.is_owned = false;
38063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38064         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38065         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
38066         return ret_arr;
38067 }
38068
38069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38070         LDKHolderCommitmentTransaction this_ptr_conv;
38071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38072         this_ptr_conv.is_owned = false;
38073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38074         LDKSignature val_ref;
38075         CHECK((*env)->GetArrayLength(env, val) == 64);
38076         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38077         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
38078 }
38079
38080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
38081         LDKHolderCommitmentTransaction this_ptr_conv;
38082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38083         this_ptr_conv.is_owned = false;
38084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38085         LDKCVec_SignatureZ val_constr;
38086         val_constr.datalen = (*env)->GetArrayLength(env, val);
38087         if (val_constr.datalen > 0)
38088                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
38089         else
38090                 val_constr.data = NULL;
38091         for (size_t i = 0; i < val_constr.datalen; i++) {
38092                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
38093                 LDKSignature val_conv_8_ref;
38094                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
38095                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
38096                 val_constr.data[i] = val_conv_8_ref;
38097         }
38098         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
38099 }
38100
38101 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
38102         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
38103 int64_t ret_ref = 0;
38104 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38105 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38106 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38107 ret_ref = (uintptr_t)ret_var.inner;
38108 if (ret_var.is_owned) {
38109         ret_ref |= 1;
38110 }
38111         return ret_ref;
38112 }
38113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38114         LDKHolderCommitmentTransaction arg_conv;
38115         arg_conv.inner = (void*)(arg & (~1));
38116         arg_conv.is_owned = false;
38117         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38118         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
38119         return ret_conv;
38120 }
38121
38122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38123         LDKHolderCommitmentTransaction orig_conv;
38124         orig_conv.inner = (void*)(orig & (~1));
38125         orig_conv.is_owned = false;
38126         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38127         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
38128         int64_t ret_ref = 0;
38129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38132         ret_ref = (uintptr_t)ret_var.inner;
38133         if (ret_var.is_owned) {
38134                 ret_ref |= 1;
38135         }
38136         return ret_ref;
38137 }
38138
38139 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38140         LDKHolderCommitmentTransaction obj_conv;
38141         obj_conv.inner = (void*)(obj & (~1));
38142         obj_conv.is_owned = false;
38143         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38144         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
38145         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38146         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38147         CVec_u8Z_free(ret_var);
38148         return ret_arr;
38149 }
38150
38151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38152         LDKu8slice ser_ref;
38153         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38154         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38155         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
38156         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
38157         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38158         return (int64_t)ret_conv;
38159 }
38160
38161 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) {
38162         LDKCommitmentTransaction commitment_tx_conv;
38163         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
38164         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
38165         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
38166         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
38167         LDKSignature counterparty_sig_ref;
38168         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
38169         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
38170         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
38171         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
38172         if (counterparty_htlc_sigs_constr.datalen > 0)
38173                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
38174         else
38175                 counterparty_htlc_sigs_constr.data = NULL;
38176         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
38177                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
38178                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
38179                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
38180                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
38181                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
38182         }
38183         LDKPublicKey holder_funding_key_ref;
38184         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
38185         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
38186         LDKPublicKey counterparty_funding_key_ref;
38187         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
38188         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
38189         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
38190         int64_t ret_ref = 0;
38191         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38192         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38194         ret_ref = (uintptr_t)ret_var.inner;
38195         if (ret_var.is_owned) {
38196                 ret_ref |= 1;
38197         }
38198         return ret_ref;
38199 }
38200
38201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38202         LDKBuiltCommitmentTransaction this_obj_conv;
38203         this_obj_conv.inner = (void*)(this_obj & (~1));
38204         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38206         BuiltCommitmentTransaction_free(this_obj_conv);
38207 }
38208
38209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
38210         LDKBuiltCommitmentTransaction this_ptr_conv;
38211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38212         this_ptr_conv.is_owned = false;
38213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38214         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
38215         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38216         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38217         Transaction_free(ret_var);
38218         return ret_arr;
38219 }
38220
38221 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38222         LDKBuiltCommitmentTransaction this_ptr_conv;
38223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38224         this_ptr_conv.is_owned = false;
38225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38226         LDKTransaction val_ref;
38227         val_ref.datalen = (*env)->GetArrayLength(env, val);
38228         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
38229         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
38230         val_ref.data_is_owned = true;
38231         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
38232 }
38233
38234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
38235         LDKBuiltCommitmentTransaction this_ptr_conv;
38236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38237         this_ptr_conv.is_owned = false;
38238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38239         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38240         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
38241         return ret_arr;
38242 }
38243
38244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38245         LDKBuiltCommitmentTransaction this_ptr_conv;
38246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38247         this_ptr_conv.is_owned = false;
38248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38249         LDKThirtyTwoBytes val_ref;
38250         CHECK((*env)->GetArrayLength(env, val) == 32);
38251         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38252         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
38253 }
38254
38255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
38256         LDKTransaction transaction_arg_ref;
38257         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
38258         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
38259         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
38260         transaction_arg_ref.data_is_owned = true;
38261         LDKThirtyTwoBytes txid_arg_ref;
38262         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
38263         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
38264         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
38265         int64_t ret_ref = 0;
38266         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38267         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38269         ret_ref = (uintptr_t)ret_var.inner;
38270         if (ret_var.is_owned) {
38271                 ret_ref |= 1;
38272         }
38273         return ret_ref;
38274 }
38275
38276 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
38277         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
38278 int64_t ret_ref = 0;
38279 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38280 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38281 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38282 ret_ref = (uintptr_t)ret_var.inner;
38283 if (ret_var.is_owned) {
38284         ret_ref |= 1;
38285 }
38286         return ret_ref;
38287 }
38288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38289         LDKBuiltCommitmentTransaction arg_conv;
38290         arg_conv.inner = (void*)(arg & (~1));
38291         arg_conv.is_owned = false;
38292         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38293         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
38294         return ret_conv;
38295 }
38296
38297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38298         LDKBuiltCommitmentTransaction orig_conv;
38299         orig_conv.inner = (void*)(orig & (~1));
38300         orig_conv.is_owned = false;
38301         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38302         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
38303         int64_t ret_ref = 0;
38304         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38305         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38307         ret_ref = (uintptr_t)ret_var.inner;
38308         if (ret_var.is_owned) {
38309                 ret_ref |= 1;
38310         }
38311         return ret_ref;
38312 }
38313
38314 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38315         LDKBuiltCommitmentTransaction obj_conv;
38316         obj_conv.inner = (void*)(obj & (~1));
38317         obj_conv.is_owned = false;
38318         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38319         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
38320         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38321         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38322         CVec_u8Z_free(ret_var);
38323         return ret_arr;
38324 }
38325
38326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38327         LDKu8slice ser_ref;
38328         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38329         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38330         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
38331         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
38332         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38333         return (int64_t)ret_conv;
38334 }
38335
38336 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) {
38337         LDKBuiltCommitmentTransaction this_arg_conv;
38338         this_arg_conv.inner = (void*)(this_arg & (~1));
38339         this_arg_conv.is_owned = false;
38340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38341         LDKu8slice funding_redeemscript_ref;
38342         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38343         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38344         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38345         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
38346         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38347         return ret_arr;
38348 }
38349
38350 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) {
38351         LDKBuiltCommitmentTransaction this_arg_conv;
38352         this_arg_conv.inner = (void*)(this_arg & (~1));
38353         this_arg_conv.is_owned = false;
38354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38355         unsigned char funding_key_arr[32];
38356         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
38357         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
38358         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
38359         LDKu8slice funding_redeemscript_ref;
38360         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38361         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38362         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38363         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
38364         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38365         return ret_arr;
38366 }
38367
38368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38369         LDKClosingTransaction this_obj_conv;
38370         this_obj_conv.inner = (void*)(this_obj & (~1));
38371         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38373         ClosingTransaction_free(this_obj_conv);
38374 }
38375
38376 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
38377         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
38378 int64_t ret_ref = 0;
38379 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38380 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38381 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38382 ret_ref = (uintptr_t)ret_var.inner;
38383 if (ret_var.is_owned) {
38384         ret_ref |= 1;
38385 }
38386         return ret_ref;
38387 }
38388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38389         LDKClosingTransaction arg_conv;
38390         arg_conv.inner = (void*)(arg & (~1));
38391         arg_conv.is_owned = false;
38392         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38393         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
38394         return ret_conv;
38395 }
38396
38397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38398         LDKClosingTransaction orig_conv;
38399         orig_conv.inner = (void*)(orig & (~1));
38400         orig_conv.is_owned = false;
38401         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38402         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
38403         int64_t ret_ref = 0;
38404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38407         ret_ref = (uintptr_t)ret_var.inner;
38408         if (ret_var.is_owned) {
38409                 ret_ref |= 1;
38410         }
38411         return ret_ref;
38412 }
38413
38414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
38415         LDKClosingTransaction o_conv;
38416         o_conv.inner = (void*)(o & (~1));
38417         o_conv.is_owned = false;
38418         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38419         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
38420         return ret_conv;
38421 }
38422
38423 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) {
38424         LDKCVec_u8Z to_holder_script_ref;
38425         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
38426         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
38427         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
38428         LDKCVec_u8Z to_counterparty_script_ref;
38429         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
38430         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
38431         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
38432         LDKOutPoint funding_outpoint_conv;
38433         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
38434         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
38435         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38436         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38437         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
38438         int64_t ret_ref = 0;
38439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38442         ret_ref = (uintptr_t)ret_var.inner;
38443         if (ret_var.is_owned) {
38444                 ret_ref |= 1;
38445         }
38446         return ret_ref;
38447 }
38448
38449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
38450         LDKClosingTransaction this_arg_conv;
38451         this_arg_conv.inner = (void*)(this_arg & (~1));
38452         this_arg_conv.is_owned = false;
38453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38454         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
38455         int64_t ret_ref = 0;
38456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38459         ret_ref = (uintptr_t)ret_var.inner;
38460         if (ret_var.is_owned) {
38461                 ret_ref |= 1;
38462         }
38463         return ret_ref;
38464 }
38465
38466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
38467         LDKClosingTransaction this_arg_conv;
38468         this_arg_conv.inner = (void*)(this_arg & (~1));
38469         this_arg_conv.is_owned = false;
38470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38471         LDKOutPoint funding_outpoint_conv;
38472         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
38473         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
38474         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
38475         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
38476         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
38477         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
38478         return (int64_t)ret_conv;
38479 }
38480
38481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38482         LDKClosingTransaction this_arg_conv;
38483         this_arg_conv.inner = (void*)(this_arg & (~1));
38484         this_arg_conv.is_owned = false;
38485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38486         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
38487         return ret_conv;
38488 }
38489
38490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38491         LDKClosingTransaction this_arg_conv;
38492         this_arg_conv.inner = (void*)(this_arg & (~1));
38493         this_arg_conv.is_owned = false;
38494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38495         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
38496         return ret_conv;
38497 }
38498
38499 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
38500         LDKClosingTransaction this_arg_conv;
38501         this_arg_conv.inner = (void*)(this_arg & (~1));
38502         this_arg_conv.is_owned = false;
38503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38504         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
38505         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38506         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38507         return ret_arr;
38508 }
38509
38510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
38511         LDKClosingTransaction this_arg_conv;
38512         this_arg_conv.inner = (void*)(this_arg & (~1));
38513         this_arg_conv.is_owned = false;
38514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38515         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
38516         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38517         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38518         return ret_arr;
38519 }
38520
38521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38522         LDKTrustedClosingTransaction this_obj_conv;
38523         this_obj_conv.inner = (void*)(this_obj & (~1));
38524         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38526         TrustedClosingTransaction_free(this_obj_conv);
38527 }
38528
38529 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
38530         LDKTrustedClosingTransaction this_arg_conv;
38531         this_arg_conv.inner = (void*)(this_arg & (~1));
38532         this_arg_conv.is_owned = false;
38533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38534         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
38535         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38536         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38537         Transaction_free(ret_var);
38538         return ret_arr;
38539 }
38540
38541 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) {
38542         LDKTrustedClosingTransaction this_arg_conv;
38543         this_arg_conv.inner = (void*)(this_arg & (~1));
38544         this_arg_conv.is_owned = false;
38545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38546         LDKu8slice funding_redeemscript_ref;
38547         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38548         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38549         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38550         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
38551         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38552         return ret_arr;
38553 }
38554
38555 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) {
38556         LDKTrustedClosingTransaction this_arg_conv;
38557         this_arg_conv.inner = (void*)(this_arg & (~1));
38558         this_arg_conv.is_owned = false;
38559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38560         unsigned char funding_key_arr[32];
38561         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
38562         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
38563         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
38564         LDKu8slice funding_redeemscript_ref;
38565         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
38566         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
38567         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38568         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
38569         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
38570         return ret_arr;
38571 }
38572
38573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38574         LDKCommitmentTransaction this_obj_conv;
38575         this_obj_conv.inner = (void*)(this_obj & (~1));
38576         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38578         CommitmentTransaction_free(this_obj_conv);
38579 }
38580
38581 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
38582         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
38583 int64_t ret_ref = 0;
38584 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38585 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38586 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38587 ret_ref = (uintptr_t)ret_var.inner;
38588 if (ret_var.is_owned) {
38589         ret_ref |= 1;
38590 }
38591         return ret_ref;
38592 }
38593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38594         LDKCommitmentTransaction arg_conv;
38595         arg_conv.inner = (void*)(arg & (~1));
38596         arg_conv.is_owned = false;
38597         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38598         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
38599         return ret_conv;
38600 }
38601
38602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38603         LDKCommitmentTransaction orig_conv;
38604         orig_conv.inner = (void*)(orig & (~1));
38605         orig_conv.is_owned = false;
38606         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38607         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
38608         int64_t ret_ref = 0;
38609         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38610         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38612         ret_ref = (uintptr_t)ret_var.inner;
38613         if (ret_var.is_owned) {
38614                 ret_ref |= 1;
38615         }
38616         return ret_ref;
38617 }
38618
38619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
38620         LDKCommitmentTransaction obj_conv;
38621         obj_conv.inner = (void*)(obj & (~1));
38622         obj_conv.is_owned = false;
38623         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38624         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
38625         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38626         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38627         CVec_u8Z_free(ret_var);
38628         return ret_arr;
38629 }
38630
38631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38632         LDKu8slice ser_ref;
38633         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38634         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38635         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
38636         *ret_conv = CommitmentTransaction_read(ser_ref);
38637         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38638         return (int64_t)ret_conv;
38639 }
38640
38641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
38642         LDKCommitmentTransaction this_arg_conv;
38643         this_arg_conv.inner = (void*)(this_arg & (~1));
38644         this_arg_conv.is_owned = false;
38645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38646         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
38647         return ret_conv;
38648 }
38649
38650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38651         LDKCommitmentTransaction this_arg_conv;
38652         this_arg_conv.inner = (void*)(this_arg & (~1));
38653         this_arg_conv.is_owned = false;
38654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38655         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
38656         return ret_conv;
38657 }
38658
38659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
38660         LDKCommitmentTransaction this_arg_conv;
38661         this_arg_conv.inner = (void*)(this_arg & (~1));
38662         this_arg_conv.is_owned = false;
38663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38664         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
38665         return ret_conv;
38666 }
38667
38668 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
38669         LDKCommitmentTransaction this_arg_conv;
38670         this_arg_conv.inner = (void*)(this_arg & (~1));
38671         this_arg_conv.is_owned = false;
38672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38673         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
38674         return ret_conv;
38675 }
38676
38677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
38678         LDKCommitmentTransaction this_arg_conv;
38679         this_arg_conv.inner = (void*)(this_arg & (~1));
38680         this_arg_conv.is_owned = false;
38681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38682         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
38683         int64_t ret_ref = 0;
38684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38687         ret_ref = (uintptr_t)ret_var.inner;
38688         if (ret_var.is_owned) {
38689                 ret_ref |= 1;
38690         }
38691         return ret_ref;
38692 }
38693
38694 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) {
38695         LDKCommitmentTransaction this_arg_conv;
38696         this_arg_conv.inner = (void*)(this_arg & (~1));
38697         this_arg_conv.is_owned = false;
38698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38699         LDKDirectedChannelTransactionParameters channel_parameters_conv;
38700         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
38701         channel_parameters_conv.is_owned = false;
38702         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
38703         LDKChannelPublicKeys broadcaster_keys_conv;
38704         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
38705         broadcaster_keys_conv.is_owned = false;
38706         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
38707         LDKChannelPublicKeys countersignatory_keys_conv;
38708         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
38709         countersignatory_keys_conv.is_owned = false;
38710         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
38711         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
38712         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
38713         return (int64_t)ret_conv;
38714 }
38715
38716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38717         LDKTrustedCommitmentTransaction this_obj_conv;
38718         this_obj_conv.inner = (void*)(this_obj & (~1));
38719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38721         TrustedCommitmentTransaction_free(this_obj_conv);
38722 }
38723
38724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
38725         LDKTrustedCommitmentTransaction this_arg_conv;
38726         this_arg_conv.inner = (void*)(this_arg & (~1));
38727         this_arg_conv.is_owned = false;
38728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38729         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38730         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
38731         return ret_arr;
38732 }
38733
38734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
38735         LDKTrustedCommitmentTransaction this_arg_conv;
38736         this_arg_conv.inner = (void*)(this_arg & (~1));
38737         this_arg_conv.is_owned = false;
38738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38739         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
38740         int64_t ret_ref = 0;
38741         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38742         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38744         ret_ref = (uintptr_t)ret_var.inner;
38745         if (ret_var.is_owned) {
38746                 ret_ref |= 1;
38747         }
38748         return ret_ref;
38749 }
38750
38751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
38752         LDKTrustedCommitmentTransaction this_arg_conv;
38753         this_arg_conv.inner = (void*)(this_arg & (~1));
38754         this_arg_conv.is_owned = false;
38755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38756         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
38757         int64_t ret_ref = 0;
38758         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38759         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38761         ret_ref = (uintptr_t)ret_var.inner;
38762         if (ret_var.is_owned) {
38763                 ret_ref |= 1;
38764         }
38765         return ret_ref;
38766 }
38767
38768 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
38769         LDKTrustedCommitmentTransaction this_arg_conv;
38770         this_arg_conv.inner = (void*)(this_arg & (~1));
38771         this_arg_conv.is_owned = false;
38772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38773         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
38774         return ret_conv;
38775 }
38776
38777 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) {
38778         LDKTrustedCommitmentTransaction this_arg_conv;
38779         this_arg_conv.inner = (void*)(this_arg & (~1));
38780         this_arg_conv.is_owned = false;
38781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38782         unsigned char htlc_base_key_arr[32];
38783         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
38784         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
38785         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
38786         LDKDirectedChannelTransactionParameters channel_parameters_conv;
38787         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
38788         channel_parameters_conv.is_owned = false;
38789         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
38790         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
38791         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
38792         return (int64_t)ret_conv;
38793 }
38794
38795 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) {
38796         LDKPublicKey broadcaster_payment_basepoint_ref;
38797         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
38798         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
38799         LDKPublicKey countersignatory_payment_basepoint_ref;
38800         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
38801         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
38802         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
38803         return ret_conv;
38804 }
38805
38806 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38807         LDKInitFeatures a_conv;
38808         a_conv.inner = (void*)(a & (~1));
38809         a_conv.is_owned = false;
38810         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38811         LDKInitFeatures b_conv;
38812         b_conv.inner = (void*)(b & (~1));
38813         b_conv.is_owned = false;
38814         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38815         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
38816         return ret_conv;
38817 }
38818
38819 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38820         LDKNodeFeatures a_conv;
38821         a_conv.inner = (void*)(a & (~1));
38822         a_conv.is_owned = false;
38823         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38824         LDKNodeFeatures b_conv;
38825         b_conv.inner = (void*)(b & (~1));
38826         b_conv.is_owned = false;
38827         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38828         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
38829         return ret_conv;
38830 }
38831
38832 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38833         LDKChannelFeatures a_conv;
38834         a_conv.inner = (void*)(a & (~1));
38835         a_conv.is_owned = false;
38836         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38837         LDKChannelFeatures b_conv;
38838         b_conv.inner = (void*)(b & (~1));
38839         b_conv.is_owned = false;
38840         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38841         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
38842         return ret_conv;
38843 }
38844
38845 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38846         LDKInvoiceFeatures a_conv;
38847         a_conv.inner = (void*)(a & (~1));
38848         a_conv.is_owned = false;
38849         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38850         LDKInvoiceFeatures b_conv;
38851         b_conv.inner = (void*)(b & (~1));
38852         b_conv.is_owned = false;
38853         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38854         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
38855         return ret_conv;
38856 }
38857
38858 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38859         LDKChannelTypeFeatures a_conv;
38860         a_conv.inner = (void*)(a & (~1));
38861         a_conv.is_owned = false;
38862         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38863         LDKChannelTypeFeatures b_conv;
38864         b_conv.inner = (void*)(b & (~1));
38865         b_conv.is_owned = false;
38866         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38867         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
38868         return ret_conv;
38869 }
38870
38871 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
38872         LDKInitFeatures ret_var = InitFeatures_clone(arg);
38873 int64_t ret_ref = 0;
38874 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38875 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38876 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38877 ret_ref = (uintptr_t)ret_var.inner;
38878 if (ret_var.is_owned) {
38879         ret_ref |= 1;
38880 }
38881         return ret_ref;
38882 }
38883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38884         LDKInitFeatures arg_conv;
38885         arg_conv.inner = (void*)(arg & (~1));
38886         arg_conv.is_owned = false;
38887         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38888         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
38889         return ret_conv;
38890 }
38891
38892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38893         LDKInitFeatures orig_conv;
38894         orig_conv.inner = (void*)(orig & (~1));
38895         orig_conv.is_owned = false;
38896         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38897         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
38898         int64_t ret_ref = 0;
38899         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38900         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38902         ret_ref = (uintptr_t)ret_var.inner;
38903         if (ret_var.is_owned) {
38904                 ret_ref |= 1;
38905         }
38906         return ret_ref;
38907 }
38908
38909 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
38910         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
38911 int64_t ret_ref = 0;
38912 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38913 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38914 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38915 ret_ref = (uintptr_t)ret_var.inner;
38916 if (ret_var.is_owned) {
38917         ret_ref |= 1;
38918 }
38919         return ret_ref;
38920 }
38921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38922         LDKNodeFeatures arg_conv;
38923         arg_conv.inner = (void*)(arg & (~1));
38924         arg_conv.is_owned = false;
38925         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38926         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
38927         return ret_conv;
38928 }
38929
38930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38931         LDKNodeFeatures orig_conv;
38932         orig_conv.inner = (void*)(orig & (~1));
38933         orig_conv.is_owned = false;
38934         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38935         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
38936         int64_t ret_ref = 0;
38937         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38938         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38940         ret_ref = (uintptr_t)ret_var.inner;
38941         if (ret_var.is_owned) {
38942                 ret_ref |= 1;
38943         }
38944         return ret_ref;
38945 }
38946
38947 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
38948         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
38949 int64_t ret_ref = 0;
38950 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38951 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38952 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38953 ret_ref = (uintptr_t)ret_var.inner;
38954 if (ret_var.is_owned) {
38955         ret_ref |= 1;
38956 }
38957         return ret_ref;
38958 }
38959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38960         LDKChannelFeatures arg_conv;
38961         arg_conv.inner = (void*)(arg & (~1));
38962         arg_conv.is_owned = false;
38963         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38964         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
38965         return ret_conv;
38966 }
38967
38968 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38969         LDKChannelFeatures orig_conv;
38970         orig_conv.inner = (void*)(orig & (~1));
38971         orig_conv.is_owned = false;
38972         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38973         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
38974         int64_t ret_ref = 0;
38975         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38976         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38978         ret_ref = (uintptr_t)ret_var.inner;
38979         if (ret_var.is_owned) {
38980                 ret_ref |= 1;
38981         }
38982         return ret_ref;
38983 }
38984
38985 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
38986         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
38987 int64_t ret_ref = 0;
38988 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38989 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38990 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38991 ret_ref = (uintptr_t)ret_var.inner;
38992 if (ret_var.is_owned) {
38993         ret_ref |= 1;
38994 }
38995         return ret_ref;
38996 }
38997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38998         LDKInvoiceFeatures arg_conv;
38999         arg_conv.inner = (void*)(arg & (~1));
39000         arg_conv.is_owned = false;
39001         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39002         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
39003         return ret_conv;
39004 }
39005
39006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39007         LDKInvoiceFeatures orig_conv;
39008         orig_conv.inner = (void*)(orig & (~1));
39009         orig_conv.is_owned = false;
39010         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39011         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
39012         int64_t ret_ref = 0;
39013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39016         ret_ref = (uintptr_t)ret_var.inner;
39017         if (ret_var.is_owned) {
39018                 ret_ref |= 1;
39019         }
39020         return ret_ref;
39021 }
39022
39023 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
39024         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
39025 int64_t ret_ref = 0;
39026 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39027 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39028 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39029 ret_ref = (uintptr_t)ret_var.inner;
39030 if (ret_var.is_owned) {
39031         ret_ref |= 1;
39032 }
39033         return ret_ref;
39034 }
39035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39036         LDKChannelTypeFeatures arg_conv;
39037         arg_conv.inner = (void*)(arg & (~1));
39038         arg_conv.is_owned = false;
39039         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39040         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
39041         return ret_conv;
39042 }
39043
39044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39045         LDKChannelTypeFeatures orig_conv;
39046         orig_conv.inner = (void*)(orig & (~1));
39047         orig_conv.is_owned = false;
39048         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39049         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
39050         int64_t ret_ref = 0;
39051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39054         ret_ref = (uintptr_t)ret_var.inner;
39055         if (ret_var.is_owned) {
39056                 ret_ref |= 1;
39057         }
39058         return ret_ref;
39059 }
39060
39061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39062         LDKInitFeatures this_obj_conv;
39063         this_obj_conv.inner = (void*)(this_obj & (~1));
39064         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39066         InitFeatures_free(this_obj_conv);
39067 }
39068
39069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39070         LDKNodeFeatures this_obj_conv;
39071         this_obj_conv.inner = (void*)(this_obj & (~1));
39072         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39074         NodeFeatures_free(this_obj_conv);
39075 }
39076
39077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39078         LDKChannelFeatures this_obj_conv;
39079         this_obj_conv.inner = (void*)(this_obj & (~1));
39080         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39082         ChannelFeatures_free(this_obj_conv);
39083 }
39084
39085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39086         LDKInvoiceFeatures this_obj_conv;
39087         this_obj_conv.inner = (void*)(this_obj & (~1));
39088         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39090         InvoiceFeatures_free(this_obj_conv);
39091 }
39092
39093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39094         LDKChannelTypeFeatures this_obj_conv;
39095         this_obj_conv.inner = (void*)(this_obj & (~1));
39096         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39098         ChannelTypeFeatures_free(this_obj_conv);
39099 }
39100
39101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
39102         LDKInitFeatures ret_var = InitFeatures_empty();
39103         int64_t ret_ref = 0;
39104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39107         ret_ref = (uintptr_t)ret_var.inner;
39108         if (ret_var.is_owned) {
39109                 ret_ref |= 1;
39110         }
39111         return ret_ref;
39112 }
39113
39114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
39115         LDKInitFeatures ret_var = InitFeatures_known();
39116         int64_t ret_ref = 0;
39117         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39118         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39120         ret_ref = (uintptr_t)ret_var.inner;
39121         if (ret_var.is_owned) {
39122                 ret_ref |= 1;
39123         }
39124         return ret_ref;
39125 }
39126
39127 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39128         LDKInitFeatures this_arg_conv;
39129         this_arg_conv.inner = (void*)(this_arg & (~1));
39130         this_arg_conv.is_owned = false;
39131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39132         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
39133         return ret_conv;
39134 }
39135
39136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
39137         LDKNodeFeatures ret_var = NodeFeatures_empty();
39138         int64_t ret_ref = 0;
39139         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39140         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39142         ret_ref = (uintptr_t)ret_var.inner;
39143         if (ret_var.is_owned) {
39144                 ret_ref |= 1;
39145         }
39146         return ret_ref;
39147 }
39148
39149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
39150         LDKNodeFeatures ret_var = NodeFeatures_known();
39151         int64_t ret_ref = 0;
39152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39155         ret_ref = (uintptr_t)ret_var.inner;
39156         if (ret_var.is_owned) {
39157                 ret_ref |= 1;
39158         }
39159         return ret_ref;
39160 }
39161
39162 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39163         LDKNodeFeatures this_arg_conv;
39164         this_arg_conv.inner = (void*)(this_arg & (~1));
39165         this_arg_conv.is_owned = false;
39166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39167         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
39168         return ret_conv;
39169 }
39170
39171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
39172         LDKChannelFeatures ret_var = ChannelFeatures_empty();
39173         int64_t ret_ref = 0;
39174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39177         ret_ref = (uintptr_t)ret_var.inner;
39178         if (ret_var.is_owned) {
39179                 ret_ref |= 1;
39180         }
39181         return ret_ref;
39182 }
39183
39184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
39185         LDKChannelFeatures ret_var = ChannelFeatures_known();
39186         int64_t ret_ref = 0;
39187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39190         ret_ref = (uintptr_t)ret_var.inner;
39191         if (ret_var.is_owned) {
39192                 ret_ref |= 1;
39193         }
39194         return ret_ref;
39195 }
39196
39197 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39198         LDKChannelFeatures this_arg_conv;
39199         this_arg_conv.inner = (void*)(this_arg & (~1));
39200         this_arg_conv.is_owned = false;
39201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39202         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
39203         return ret_conv;
39204 }
39205
39206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
39207         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
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_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
39220         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
39221         int64_t ret_ref = 0;
39222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39225         ret_ref = (uintptr_t)ret_var.inner;
39226         if (ret_var.is_owned) {
39227                 ret_ref |= 1;
39228         }
39229         return ret_ref;
39230 }
39231
39232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39233         LDKInvoiceFeatures this_arg_conv;
39234         this_arg_conv.inner = (void*)(this_arg & (~1));
39235         this_arg_conv.is_owned = false;
39236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39237         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
39238         return ret_conv;
39239 }
39240
39241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
39242         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
39243         int64_t ret_ref = 0;
39244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39247         ret_ref = (uintptr_t)ret_var.inner;
39248         if (ret_var.is_owned) {
39249                 ret_ref |= 1;
39250         }
39251         return ret_ref;
39252 }
39253
39254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
39255         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
39256         int64_t ret_ref = 0;
39257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39260         ret_ref = (uintptr_t)ret_var.inner;
39261         if (ret_var.is_owned) {
39262                 ret_ref |= 1;
39263         }
39264         return ret_ref;
39265 }
39266
39267 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
39268         LDKChannelTypeFeatures this_arg_conv;
39269         this_arg_conv.inner = (void*)(this_arg & (~1));
39270         this_arg_conv.is_owned = false;
39271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39272         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
39273         return ret_conv;
39274 }
39275
39276 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39277         LDKInitFeatures obj_conv;
39278         obj_conv.inner = (void*)(obj & (~1));
39279         obj_conv.is_owned = false;
39280         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39281         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
39282         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39283         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39284         CVec_u8Z_free(ret_var);
39285         return ret_arr;
39286 }
39287
39288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39289         LDKu8slice ser_ref;
39290         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39291         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39292         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
39293         *ret_conv = InitFeatures_read(ser_ref);
39294         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39295         return (int64_t)ret_conv;
39296 }
39297
39298 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39299         LDKChannelFeatures obj_conv;
39300         obj_conv.inner = (void*)(obj & (~1));
39301         obj_conv.is_owned = false;
39302         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39303         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
39304         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39305         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39306         CVec_u8Z_free(ret_var);
39307         return ret_arr;
39308 }
39309
39310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39311         LDKu8slice ser_ref;
39312         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39313         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39314         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
39315         *ret_conv = ChannelFeatures_read(ser_ref);
39316         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39317         return (int64_t)ret_conv;
39318 }
39319
39320 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39321         LDKNodeFeatures obj_conv;
39322         obj_conv.inner = (void*)(obj & (~1));
39323         obj_conv.is_owned = false;
39324         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39325         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
39326         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39327         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39328         CVec_u8Z_free(ret_var);
39329         return ret_arr;
39330 }
39331
39332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39333         LDKu8slice ser_ref;
39334         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39335         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39336         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
39337         *ret_conv = NodeFeatures_read(ser_ref);
39338         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39339         return (int64_t)ret_conv;
39340 }
39341
39342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39343         LDKInvoiceFeatures obj_conv;
39344         obj_conv.inner = (void*)(obj & (~1));
39345         obj_conv.is_owned = false;
39346         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39347         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
39348         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39349         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39350         CVec_u8Z_free(ret_var);
39351         return ret_arr;
39352 }
39353
39354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39355         LDKu8slice ser_ref;
39356         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39357         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39358         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
39359         *ret_conv = InvoiceFeatures_read(ser_ref);
39360         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39361         return (int64_t)ret_conv;
39362 }
39363
39364 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39365         LDKChannelTypeFeatures obj_conv;
39366         obj_conv.inner = (void*)(obj & (~1));
39367         obj_conv.is_owned = false;
39368         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39369         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
39370         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39371         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39372         CVec_u8Z_free(ret_var);
39373         return ret_arr;
39374 }
39375
39376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39377         LDKu8slice ser_ref;
39378         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39379         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39380         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
39381         *ret_conv = ChannelTypeFeatures_read(ser_ref);
39382         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39383         return (int64_t)ret_conv;
39384 }
39385
39386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39387         LDKShutdownScript this_obj_conv;
39388         this_obj_conv.inner = (void*)(this_obj & (~1));
39389         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39391         ShutdownScript_free(this_obj_conv);
39392 }
39393
39394 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
39395         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
39396 int64_t ret_ref = 0;
39397 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39398 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39399 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39400 ret_ref = (uintptr_t)ret_var.inner;
39401 if (ret_var.is_owned) {
39402         ret_ref |= 1;
39403 }
39404         return ret_ref;
39405 }
39406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39407         LDKShutdownScript arg_conv;
39408         arg_conv.inner = (void*)(arg & (~1));
39409         arg_conv.is_owned = false;
39410         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39411         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
39412         return ret_conv;
39413 }
39414
39415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39416         LDKShutdownScript orig_conv;
39417         orig_conv.inner = (void*)(orig & (~1));
39418         orig_conv.is_owned = false;
39419         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39420         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
39421         int64_t ret_ref = 0;
39422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39425         ret_ref = (uintptr_t)ret_var.inner;
39426         if (ret_var.is_owned) {
39427                 ret_ref |= 1;
39428         }
39429         return ret_ref;
39430 }
39431
39432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39433         LDKInvalidShutdownScript this_obj_conv;
39434         this_obj_conv.inner = (void*)(this_obj & (~1));
39435         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39437         InvalidShutdownScript_free(this_obj_conv);
39438 }
39439
39440 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
39441         LDKInvalidShutdownScript this_ptr_conv;
39442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39443         this_ptr_conv.is_owned = false;
39444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39445         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
39446         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39447         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39448         return ret_arr;
39449 }
39450
39451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39452         LDKInvalidShutdownScript this_ptr_conv;
39453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39454         this_ptr_conv.is_owned = false;
39455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39456         LDKCVec_u8Z val_ref;
39457         val_ref.datalen = (*env)->GetArrayLength(env, val);
39458         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
39459         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
39460         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
39461 }
39462
39463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
39464         LDKCVec_u8Z script_arg_ref;
39465         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
39466         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
39467         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
39468         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
39469         int64_t ret_ref = 0;
39470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39473         ret_ref = (uintptr_t)ret_var.inner;
39474         if (ret_var.is_owned) {
39475                 ret_ref |= 1;
39476         }
39477         return ret_ref;
39478 }
39479
39480 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
39481         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
39482 int64_t ret_ref = 0;
39483 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39484 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39485 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39486 ret_ref = (uintptr_t)ret_var.inner;
39487 if (ret_var.is_owned) {
39488         ret_ref |= 1;
39489 }
39490         return ret_ref;
39491 }
39492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39493         LDKInvalidShutdownScript arg_conv;
39494         arg_conv.inner = (void*)(arg & (~1));
39495         arg_conv.is_owned = false;
39496         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39497         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
39498         return ret_conv;
39499 }
39500
39501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39502         LDKInvalidShutdownScript orig_conv;
39503         orig_conv.inner = (void*)(orig & (~1));
39504         orig_conv.is_owned = false;
39505         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39506         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
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
39518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
39519         LDKShutdownScript obj_conv;
39520         obj_conv.inner = (void*)(obj & (~1));
39521         obj_conv.is_owned = false;
39522         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39523         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
39524         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39525         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39526         CVec_u8Z_free(ret_var);
39527         return ret_arr;
39528 }
39529
39530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39531         LDKu8slice ser_ref;
39532         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39533         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39534         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
39535         *ret_conv = ShutdownScript_read(ser_ref);
39536         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39537         return (int64_t)ret_conv;
39538 }
39539
39540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
39541         unsigned char pubkey_hash_arr[20];
39542         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
39543         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
39544         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
39545         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
39546         int64_t ret_ref = 0;
39547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39550         ret_ref = (uintptr_t)ret_var.inner;
39551         if (ret_var.is_owned) {
39552                 ret_ref |= 1;
39553         }
39554         return ret_ref;
39555 }
39556
39557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
39558         unsigned char script_hash_arr[32];
39559         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
39560         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
39561         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
39562         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
39563         int64_t ret_ref = 0;
39564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39567         ret_ref = (uintptr_t)ret_var.inner;
39568         if (ret_var.is_owned) {
39569                 ret_ref |= 1;
39570         }
39571         return ret_ref;
39572 }
39573
39574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
39575         LDKu8slice program_ref;
39576         program_ref.datalen = (*env)->GetArrayLength(env, program);
39577         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
39578         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
39579         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
39580         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
39581         return (int64_t)ret_conv;
39582 }
39583
39584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
39585         LDKShutdownScript this_arg_conv;
39586         this_arg_conv.inner = (void*)(this_arg & (~1));
39587         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39589         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
39590         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
39591         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39592         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39593         CVec_u8Z_free(ret_var);
39594         return ret_arr;
39595 }
39596
39597 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
39598         LDKShutdownScript this_arg_conv;
39599         this_arg_conv.inner = (void*)(this_arg & (~1));
39600         this_arg_conv.is_owned = false;
39601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39602         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39603         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
39604         return ret_arr;
39605 }
39606
39607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
39608         LDKShutdownScript this_arg_conv;
39609         this_arg_conv.inner = (void*)(this_arg & (~1));
39610         this_arg_conv.is_owned = false;
39611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39612         LDKInitFeatures features_conv;
39613         features_conv.inner = (void*)(features & (~1));
39614         features_conv.is_owned = false;
39615         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
39616         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
39617         return ret_conv;
39618 }
39619
39620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39621         if ((this_ptr & 1) != 0) return;
39622         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39623         CHECK_ACCESS(this_ptr_ptr);
39624         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
39625         FREE((void*)this_ptr);
39626         CustomMessageReader_free(this_ptr_conv);
39627 }
39628
39629 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
39630         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39631         *ret_ret = Type_clone(arg);
39632         return (int64_t)ret_ret;
39633 }
39634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39635         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
39636         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
39637         LDKType* arg_conv = (LDKType*)arg_ptr;
39638         int64_t ret_conv = Type_clone_ptr(arg_conv);
39639         return ret_conv;
39640 }
39641
39642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39643         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
39644         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
39645         LDKType* orig_conv = (LDKType*)orig_ptr;
39646         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
39647         *ret_ret = Type_clone(orig_conv);
39648         return (int64_t)ret_ret;
39649 }
39650
39651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39652         if ((this_ptr & 1) != 0) return;
39653         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39654         CHECK_ACCESS(this_ptr_ptr);
39655         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
39656         FREE((void*)this_ptr);
39657         Type_free(this_ptr_conv);
39658 }
39659
39660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39661         LDKNodeId this_obj_conv;
39662         this_obj_conv.inner = (void*)(this_obj & (~1));
39663         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39665         NodeId_free(this_obj_conv);
39666 }
39667
39668 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
39669         LDKNodeId ret_var = NodeId_clone(arg);
39670 int64_t ret_ref = 0;
39671 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39672 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39673 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39674 ret_ref = (uintptr_t)ret_var.inner;
39675 if (ret_var.is_owned) {
39676         ret_ref |= 1;
39677 }
39678         return ret_ref;
39679 }
39680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39681         LDKNodeId arg_conv;
39682         arg_conv.inner = (void*)(arg & (~1));
39683         arg_conv.is_owned = false;
39684         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39685         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
39686         return ret_conv;
39687 }
39688
39689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39690         LDKNodeId orig_conv;
39691         orig_conv.inner = (void*)(orig & (~1));
39692         orig_conv.is_owned = false;
39693         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39694         LDKNodeId ret_var = NodeId_clone(&orig_conv);
39695         int64_t ret_ref = 0;
39696         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39697         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39699         ret_ref = (uintptr_t)ret_var.inner;
39700         if (ret_var.is_owned) {
39701                 ret_ref |= 1;
39702         }
39703         return ret_ref;
39704 }
39705
39706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
39707         LDKPublicKey pubkey_ref;
39708         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
39709         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
39710         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
39711         int64_t ret_ref = 0;
39712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39715         ret_ref = (uintptr_t)ret_var.inner;
39716         if (ret_var.is_owned) {
39717                 ret_ref |= 1;
39718         }
39719         return ret_ref;
39720 }
39721
39722 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
39723         LDKNodeId this_arg_conv;
39724         this_arg_conv.inner = (void*)(this_arg & (~1));
39725         this_arg_conv.is_owned = false;
39726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39727         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
39728         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39729         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39730         return ret_arr;
39731 }
39732
39733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
39734         LDKNodeId o_conv;
39735         o_conv.inner = (void*)(o & (~1));
39736         o_conv.is_owned = false;
39737         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39738         int64_t ret_conv = NodeId_hash(&o_conv);
39739         return ret_conv;
39740 }
39741
39742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
39743         LDKNodeId obj_conv;
39744         obj_conv.inner = (void*)(obj & (~1));
39745         obj_conv.is_owned = false;
39746         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39747         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
39748         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39749         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39750         CVec_u8Z_free(ret_var);
39751         return ret_arr;
39752 }
39753
39754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39755         LDKu8slice ser_ref;
39756         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39757         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39758         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
39759         *ret_conv = NodeId_read(ser_ref);
39760         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39761         return (int64_t)ret_conv;
39762 }
39763
39764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39765         LDKNetworkGraph this_obj_conv;
39766         this_obj_conv.inner = (void*)(this_obj & (~1));
39767         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39769         NetworkGraph_free(this_obj_conv);
39770 }
39771
39772 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
39773         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
39774 int64_t ret_ref = 0;
39775 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39776 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39777 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39778 ret_ref = (uintptr_t)ret_var.inner;
39779 if (ret_var.is_owned) {
39780         ret_ref |= 1;
39781 }
39782         return ret_ref;
39783 }
39784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39785         LDKNetworkGraph arg_conv;
39786         arg_conv.inner = (void*)(arg & (~1));
39787         arg_conv.is_owned = false;
39788         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39789         int64_t ret_conv = NetworkGraph_clone_ptr(&arg_conv);
39790         return ret_conv;
39791 }
39792
39793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39794         LDKNetworkGraph orig_conv;
39795         orig_conv.inner = (void*)(orig & (~1));
39796         orig_conv.is_owned = false;
39797         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39798         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
39799         int64_t ret_ref = 0;
39800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39803         ret_ref = (uintptr_t)ret_var.inner;
39804         if (ret_var.is_owned) {
39805                 ret_ref |= 1;
39806         }
39807         return ret_ref;
39808 }
39809
39810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39811         LDKReadOnlyNetworkGraph this_obj_conv;
39812         this_obj_conv.inner = (void*)(this_obj & (~1));
39813         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39815         ReadOnlyNetworkGraph_free(this_obj_conv);
39816 }
39817
39818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39819         if ((this_ptr & 1) != 0) return;
39820         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39821         CHECK_ACCESS(this_ptr_ptr);
39822         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
39823         FREE((void*)this_ptr);
39824         NetworkUpdate_free(this_ptr_conv);
39825 }
39826
39827 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
39828         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39829         *ret_copy = NetworkUpdate_clone(arg);
39830 int64_t ret_ref = (uintptr_t)ret_copy;
39831         return ret_ref;
39832 }
39833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39834         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
39835         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
39836         return ret_conv;
39837 }
39838
39839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39840         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
39841         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39842         *ret_copy = NetworkUpdate_clone(orig_conv);
39843         int64_t ret_ref = (uintptr_t)ret_copy;
39844         return ret_ref;
39845 }
39846
39847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
39848         LDKChannelUpdate msg_conv;
39849         msg_conv.inner = (void*)(msg & (~1));
39850         msg_conv.is_owned = (msg & 1) || (msg == 0);
39851         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39852         msg_conv = ChannelUpdate_clone(&msg_conv);
39853         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39854         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
39855         int64_t ret_ref = (uintptr_t)ret_copy;
39856         return ret_ref;
39857 }
39858
39859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
39860         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39861         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
39862         int64_t ret_ref = (uintptr_t)ret_copy;
39863         return ret_ref;
39864 }
39865
39866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
39867         LDKPublicKey node_id_ref;
39868         CHECK((*env)->GetArrayLength(env, node_id) == 33);
39869         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
39870         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
39871         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
39872         int64_t ret_ref = (uintptr_t)ret_copy;
39873         return ret_ref;
39874 }
39875
39876 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
39877         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
39878         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
39879         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39880         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39881         CVec_u8Z_free(ret_var);
39882         return ret_arr;
39883 }
39884
39885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39886         LDKu8slice ser_ref;
39887         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39888         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39889         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
39890         *ret_conv = NetworkUpdate_read(ser_ref);
39891         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39892         return (int64_t)ret_conv;
39893 }
39894
39895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39896         LDKNetGraphMsgHandler this_arg_conv;
39897         this_arg_conv.inner = (void*)(this_arg & (~1));
39898         this_arg_conv.is_owned = false;
39899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39900         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
39901         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
39902         return (int64_t)ret_ret;
39903 }
39904
39905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39906         LDKNetGraphMsgHandler this_obj_conv;
39907         this_obj_conv.inner = (void*)(this_obj & (~1));
39908         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39910         NetGraphMsgHandler_free(this_obj_conv);
39911 }
39912
39913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
39914         LDKNetworkGraph network_graph_conv;
39915         network_graph_conv.inner = (void*)(network_graph & (~1));
39916         network_graph_conv.is_owned = false;
39917         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39918         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39919         CHECK_ACCESS(chain_access_ptr);
39920         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39921         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39922         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39923                 // Manually implement clone for Java trait instances
39924                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39925                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39926                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39927                 }
39928         }
39929         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39930         CHECK_ACCESS(logger_ptr);
39931         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39932         if (logger_conv.free == LDKLogger_JCalls_free) {
39933                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39934                 LDKLogger_JCalls_cloned(&logger_conv);
39935         }
39936         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
39937         int64_t ret_ref = 0;
39938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39941         ret_ref = (uintptr_t)ret_var.inner;
39942         if (ret_var.is_owned) {
39943                 ret_ref |= 1;
39944         }
39945         return ret_ref;
39946 }
39947
39948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
39949         LDKNetGraphMsgHandler this_arg_conv;
39950         this_arg_conv.inner = (void*)(this_arg & (~1));
39951         this_arg_conv.is_owned = false;
39952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39953         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39954         CHECK_ACCESS(chain_access_ptr);
39955         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39956         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39957         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39958                 // Manually implement clone for Java trait instances
39959                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39960                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39961                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39962                 }
39963         }
39964         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
39965 }
39966
39967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
39968         LDKNetGraphMsgHandler this_arg_conv;
39969         this_arg_conv.inner = (void*)(this_arg & (~1));
39970         this_arg_conv.is_owned = false;
39971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39972         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
39973         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
39974         return (int64_t)ret_ret;
39975 }
39976
39977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
39978         LDKNetGraphMsgHandler this_arg_conv;
39979         this_arg_conv.inner = (void*)(this_arg & (~1));
39980         this_arg_conv.is_owned = false;
39981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39982         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
39983         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
39984         return (int64_t)ret_ret;
39985 }
39986
39987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39988         LDKChannelUpdateInfo this_obj_conv;
39989         this_obj_conv.inner = (void*)(this_obj & (~1));
39990         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39992         ChannelUpdateInfo_free(this_obj_conv);
39993 }
39994
39995 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
39996         LDKChannelUpdateInfo this_ptr_conv;
39997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39998         this_ptr_conv.is_owned = false;
39999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40000         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
40001         return ret_conv;
40002 }
40003
40004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40005         LDKChannelUpdateInfo this_ptr_conv;
40006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40007         this_ptr_conv.is_owned = false;
40008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40009         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
40010 }
40011
40012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
40013         LDKChannelUpdateInfo this_ptr_conv;
40014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40015         this_ptr_conv.is_owned = false;
40016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40017         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
40018         return ret_conv;
40019 }
40020
40021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
40022         LDKChannelUpdateInfo this_ptr_conv;
40023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40024         this_ptr_conv.is_owned = false;
40025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40026         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
40027 }
40028
40029 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
40030         LDKChannelUpdateInfo this_ptr_conv;
40031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40032         this_ptr_conv.is_owned = false;
40033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40034         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
40035         return ret_conv;
40036 }
40037
40038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
40039         LDKChannelUpdateInfo this_ptr_conv;
40040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40041         this_ptr_conv.is_owned = false;
40042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40043         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
40044 }
40045
40046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40047         LDKChannelUpdateInfo this_ptr_conv;
40048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40049         this_ptr_conv.is_owned = false;
40050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40051         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
40052         return ret_conv;
40053 }
40054
40055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40056         LDKChannelUpdateInfo this_ptr_conv;
40057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40058         this_ptr_conv.is_owned = false;
40059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40060         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
40061 }
40062
40063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40064         LDKChannelUpdateInfo this_ptr_conv;
40065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40066         this_ptr_conv.is_owned = false;
40067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40068         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40069         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
40070         int64_t ret_ref = (uintptr_t)ret_copy;
40071         return ret_ref;
40072 }
40073
40074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40075         LDKChannelUpdateInfo this_ptr_conv;
40076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40077         this_ptr_conv.is_owned = false;
40078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40079         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
40080         CHECK_ACCESS(val_ptr);
40081         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
40082         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
40083         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
40084 }
40085
40086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
40087         LDKChannelUpdateInfo this_ptr_conv;
40088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40089         this_ptr_conv.is_owned = false;
40090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40091         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
40092         int64_t ret_ref = 0;
40093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40096         ret_ref = (uintptr_t)ret_var.inner;
40097         if (ret_var.is_owned) {
40098                 ret_ref |= 1;
40099         }
40100         return ret_ref;
40101 }
40102
40103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40104         LDKChannelUpdateInfo this_ptr_conv;
40105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40106         this_ptr_conv.is_owned = false;
40107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40108         LDKRoutingFees val_conv;
40109         val_conv.inner = (void*)(val & (~1));
40110         val_conv.is_owned = (val & 1) || (val == 0);
40111         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40112         val_conv = RoutingFees_clone(&val_conv);
40113         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
40114 }
40115
40116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
40117         LDKChannelUpdateInfo this_ptr_conv;
40118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40119         this_ptr_conv.is_owned = false;
40120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40121         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
40122         int64_t ret_ref = 0;
40123         if ((uintptr_t)ret_var.inner > 4096) {
40124                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40125                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40127                 ret_ref = (uintptr_t)ret_var.inner;
40128                 if (ret_var.is_owned) {
40129                         ret_ref |= 1;
40130                 }
40131         }
40132         return ret_ref;
40133 }
40134
40135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40136         LDKChannelUpdateInfo this_ptr_conv;
40137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40138         this_ptr_conv.is_owned = false;
40139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40140         LDKChannelUpdate val_conv;
40141         val_conv.inner = (void*)(val & (~1));
40142         val_conv.is_owned = (val & 1) || (val == 0);
40143         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40144         val_conv = ChannelUpdate_clone(&val_conv);
40145         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
40146 }
40147
40148 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) {
40149         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
40150         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
40151         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
40152         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
40153         LDKRoutingFees fees_arg_conv;
40154         fees_arg_conv.inner = (void*)(fees_arg & (~1));
40155         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
40156         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
40157         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
40158         LDKChannelUpdate last_update_message_arg_conv;
40159         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
40160         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
40161         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
40162         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
40163         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);
40164         int64_t ret_ref = 0;
40165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40168         ret_ref = (uintptr_t)ret_var.inner;
40169         if (ret_var.is_owned) {
40170                 ret_ref |= 1;
40171         }
40172         return ret_ref;
40173 }
40174
40175 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
40176         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
40177 int64_t ret_ref = 0;
40178 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40179 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40180 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40181 ret_ref = (uintptr_t)ret_var.inner;
40182 if (ret_var.is_owned) {
40183         ret_ref |= 1;
40184 }
40185         return ret_ref;
40186 }
40187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40188         LDKChannelUpdateInfo arg_conv;
40189         arg_conv.inner = (void*)(arg & (~1));
40190         arg_conv.is_owned = false;
40191         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40192         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
40193         return ret_conv;
40194 }
40195
40196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40197         LDKChannelUpdateInfo orig_conv;
40198         orig_conv.inner = (void*)(orig & (~1));
40199         orig_conv.is_owned = false;
40200         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40201         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
40202         int64_t ret_ref = 0;
40203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40206         ret_ref = (uintptr_t)ret_var.inner;
40207         if (ret_var.is_owned) {
40208                 ret_ref |= 1;
40209         }
40210         return ret_ref;
40211 }
40212
40213 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
40214         LDKChannelUpdateInfo obj_conv;
40215         obj_conv.inner = (void*)(obj & (~1));
40216         obj_conv.is_owned = false;
40217         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40218         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
40219         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40220         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40221         CVec_u8Z_free(ret_var);
40222         return ret_arr;
40223 }
40224
40225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40226         LDKu8slice ser_ref;
40227         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40228         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40229         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
40230         *ret_conv = ChannelUpdateInfo_read(ser_ref);
40231         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40232         return (int64_t)ret_conv;
40233 }
40234
40235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40236         LDKChannelInfo this_obj_conv;
40237         this_obj_conv.inner = (void*)(this_obj & (~1));
40238         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40240         ChannelInfo_free(this_obj_conv);
40241 }
40242
40243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40244         LDKChannelInfo this_ptr_conv;
40245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40246         this_ptr_conv.is_owned = false;
40247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40248         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
40249         int64_t ret_ref = 0;
40250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40253         ret_ref = (uintptr_t)ret_var.inner;
40254         if (ret_var.is_owned) {
40255                 ret_ref |= 1;
40256         }
40257         return ret_ref;
40258 }
40259
40260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40261         LDKChannelInfo this_ptr_conv;
40262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40263         this_ptr_conv.is_owned = false;
40264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40265         LDKChannelFeatures val_conv;
40266         val_conv.inner = (void*)(val & (~1));
40267         val_conv.is_owned = (val & 1) || (val == 0);
40268         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40269         val_conv = ChannelFeatures_clone(&val_conv);
40270         ChannelInfo_set_features(&this_ptr_conv, val_conv);
40271 }
40272
40273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
40274         LDKChannelInfo this_ptr_conv;
40275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40276         this_ptr_conv.is_owned = false;
40277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40278         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_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_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40291         LDKChannelInfo this_ptr_conv;
40292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40293         this_ptr_conv.is_owned = false;
40294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40295         LDKNodeId val_conv;
40296         val_conv.inner = (void*)(val & (~1));
40297         val_conv.is_owned = (val & 1) || (val == 0);
40298         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40299         val_conv = NodeId_clone(&val_conv);
40300         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
40301 }
40302
40303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
40304         LDKChannelInfo this_ptr_conv;
40305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40306         this_ptr_conv.is_owned = false;
40307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40308         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
40309         int64_t ret_ref = 0;
40310         if ((uintptr_t)ret_var.inner > 4096) {
40311                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40312                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40314                 ret_ref = (uintptr_t)ret_var.inner;
40315                 if (ret_var.is_owned) {
40316                         ret_ref |= 1;
40317                 }
40318         }
40319         return ret_ref;
40320 }
40321
40322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40323         LDKChannelInfo this_ptr_conv;
40324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40325         this_ptr_conv.is_owned = false;
40326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40327         LDKChannelUpdateInfo val_conv;
40328         val_conv.inner = (void*)(val & (~1));
40329         val_conv.is_owned = (val & 1) || (val == 0);
40330         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40331         val_conv = ChannelUpdateInfo_clone(&val_conv);
40332         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
40333 }
40334
40335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
40336         LDKChannelInfo this_ptr_conv;
40337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40338         this_ptr_conv.is_owned = false;
40339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40340         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
40341         int64_t ret_ref = 0;
40342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40345         ret_ref = (uintptr_t)ret_var.inner;
40346         if (ret_var.is_owned) {
40347                 ret_ref |= 1;
40348         }
40349         return ret_ref;
40350 }
40351
40352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40353         LDKChannelInfo this_ptr_conv;
40354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40355         this_ptr_conv.is_owned = false;
40356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40357         LDKNodeId val_conv;
40358         val_conv.inner = (void*)(val & (~1));
40359         val_conv.is_owned = (val & 1) || (val == 0);
40360         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40361         val_conv = NodeId_clone(&val_conv);
40362         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
40363 }
40364
40365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
40366         LDKChannelInfo this_ptr_conv;
40367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40368         this_ptr_conv.is_owned = false;
40369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40370         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
40371         int64_t ret_ref = 0;
40372         if ((uintptr_t)ret_var.inner > 4096) {
40373                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40374                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40376                 ret_ref = (uintptr_t)ret_var.inner;
40377                 if (ret_var.is_owned) {
40378                         ret_ref |= 1;
40379                 }
40380         }
40381         return ret_ref;
40382 }
40383
40384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40385         LDKChannelInfo this_ptr_conv;
40386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40387         this_ptr_conv.is_owned = false;
40388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40389         LDKChannelUpdateInfo val_conv;
40390         val_conv.inner = (void*)(val & (~1));
40391         val_conv.is_owned = (val & 1) || (val == 0);
40392         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40393         val_conv = ChannelUpdateInfo_clone(&val_conv);
40394         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
40395 }
40396
40397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
40398         LDKChannelInfo this_ptr_conv;
40399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40400         this_ptr_conv.is_owned = false;
40401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40402         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40403         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
40404         int64_t ret_ref = (uintptr_t)ret_copy;
40405         return ret_ref;
40406 }
40407
40408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40409         LDKChannelInfo this_ptr_conv;
40410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40411         this_ptr_conv.is_owned = false;
40412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40413         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
40414         CHECK_ACCESS(val_ptr);
40415         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
40416         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
40417         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
40418 }
40419
40420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
40421         LDKChannelInfo this_ptr_conv;
40422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40423         this_ptr_conv.is_owned = false;
40424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40425         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
40426         int64_t ret_ref = 0;
40427         if ((uintptr_t)ret_var.inner > 4096) {
40428                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40429                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40431                 ret_ref = (uintptr_t)ret_var.inner;
40432                 if (ret_var.is_owned) {
40433                         ret_ref |= 1;
40434                 }
40435         }
40436         return ret_ref;
40437 }
40438
40439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40440         LDKChannelInfo this_ptr_conv;
40441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40442         this_ptr_conv.is_owned = false;
40443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40444         LDKChannelAnnouncement val_conv;
40445         val_conv.inner = (void*)(val & (~1));
40446         val_conv.is_owned = (val & 1) || (val == 0);
40447         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40448         val_conv = ChannelAnnouncement_clone(&val_conv);
40449         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
40450 }
40451
40452 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
40453         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
40454 int64_t ret_ref = 0;
40455 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40456 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40457 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40458 ret_ref = (uintptr_t)ret_var.inner;
40459 if (ret_var.is_owned) {
40460         ret_ref |= 1;
40461 }
40462         return ret_ref;
40463 }
40464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40465         LDKChannelInfo arg_conv;
40466         arg_conv.inner = (void*)(arg & (~1));
40467         arg_conv.is_owned = false;
40468         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40469         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
40470         return ret_conv;
40471 }
40472
40473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40474         LDKChannelInfo orig_conv;
40475         orig_conv.inner = (void*)(orig & (~1));
40476         orig_conv.is_owned = false;
40477         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40478         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
40479         int64_t ret_ref = 0;
40480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40483         ret_ref = (uintptr_t)ret_var.inner;
40484         if (ret_var.is_owned) {
40485                 ret_ref |= 1;
40486         }
40487         return ret_ref;
40488 }
40489
40490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
40491         LDKChannelInfo obj_conv;
40492         obj_conv.inner = (void*)(obj & (~1));
40493         obj_conv.is_owned = false;
40494         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40495         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
40496         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40497         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40498         CVec_u8Z_free(ret_var);
40499         return ret_arr;
40500 }
40501
40502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40503         LDKu8slice ser_ref;
40504         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40505         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40506         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
40507         *ret_conv = ChannelInfo_read(ser_ref);
40508         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40509         return (int64_t)ret_conv;
40510 }
40511
40512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40513         LDKDirectedChannelInfo this_obj_conv;
40514         this_obj_conv.inner = (void*)(this_obj & (~1));
40515         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40517         DirectedChannelInfo_free(this_obj_conv);
40518 }
40519
40520 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
40521         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
40522 int64_t ret_ref = 0;
40523 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40524 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40525 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40526 ret_ref = (uintptr_t)ret_var.inner;
40527 if (ret_var.is_owned) {
40528         ret_ref |= 1;
40529 }
40530         return ret_ref;
40531 }
40532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40533         LDKDirectedChannelInfo arg_conv;
40534         arg_conv.inner = (void*)(arg & (~1));
40535         arg_conv.is_owned = false;
40536         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40537         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
40538         return ret_conv;
40539 }
40540
40541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40542         LDKDirectedChannelInfo orig_conv;
40543         orig_conv.inner = (void*)(orig & (~1));
40544         orig_conv.is_owned = false;
40545         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40546         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
40547         int64_t ret_ref = 0;
40548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40551         ret_ref = (uintptr_t)ret_var.inner;
40552         if (ret_var.is_owned) {
40553                 ret_ref |= 1;
40554         }
40555         return ret_ref;
40556 }
40557
40558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
40559         LDKDirectedChannelInfo this_arg_conv;
40560         this_arg_conv.inner = (void*)(this_arg & (~1));
40561         this_arg_conv.is_owned = false;
40562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40563         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
40564         int64_t ret_ref = 0;
40565         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40566         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40568         ret_ref = (uintptr_t)ret_var.inner;
40569         if (ret_var.is_owned) {
40570                 ret_ref |= 1;
40571         }
40572         return ret_ref;
40573 }
40574
40575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
40576         LDKDirectedChannelInfo this_arg_conv;
40577         this_arg_conv.inner = (void*)(this_arg & (~1));
40578         this_arg_conv.is_owned = false;
40579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40580         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
40581         int64_t ret_ref = 0;
40582         if ((uintptr_t)ret_var.inner > 4096) {
40583                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40584                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40586                 ret_ref = (uintptr_t)ret_var.inner;
40587                 if (ret_var.is_owned) {
40588                         ret_ref |= 1;
40589                 }
40590         }
40591         return ret_ref;
40592 }
40593
40594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
40595         LDKDirectedChannelInfo this_arg_conv;
40596         this_arg_conv.inner = (void*)(this_arg & (~1));
40597         this_arg_conv.is_owned = false;
40598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40599         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40600         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
40601         int64_t ret_ref = (uintptr_t)ret_copy;
40602         return ret_ref;
40603 }
40604
40605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40606         if ((this_ptr & 1) != 0) return;
40607         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40608         CHECK_ACCESS(this_ptr_ptr);
40609         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
40610         FREE((void*)this_ptr);
40611         EffectiveCapacity_free(this_ptr_conv);
40612 }
40613
40614 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
40615         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40616         *ret_copy = EffectiveCapacity_clone(arg);
40617 int64_t ret_ref = (uintptr_t)ret_copy;
40618         return ret_ref;
40619 }
40620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40621         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
40622         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
40623         return ret_conv;
40624 }
40625
40626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40627         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
40628         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40629         *ret_copy = EffectiveCapacity_clone(orig_conv);
40630         int64_t ret_ref = (uintptr_t)ret_copy;
40631         return ret_ref;
40632 }
40633
40634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
40635         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40636         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
40637         int64_t ret_ref = (uintptr_t)ret_copy;
40638         return ret_ref;
40639 }
40640
40641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
40642         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40643         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
40644         int64_t ret_ref = (uintptr_t)ret_copy;
40645         return ret_ref;
40646 }
40647
40648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat) {
40649         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40650         *ret_copy = EffectiveCapacity_total(capacity_msat);
40651         int64_t ret_ref = (uintptr_t)ret_copy;
40652         return ret_ref;
40653 }
40654
40655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
40656         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40657         *ret_copy = EffectiveCapacity_infinite();
40658         int64_t ret_ref = (uintptr_t)ret_copy;
40659         return ret_ref;
40660 }
40661
40662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
40663         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
40664         *ret_copy = EffectiveCapacity_unknown();
40665         int64_t ret_ref = (uintptr_t)ret_copy;
40666         return ret_ref;
40667 }
40668
40669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
40670         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
40671         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
40672         return ret_conv;
40673 }
40674
40675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40676         LDKRoutingFees this_obj_conv;
40677         this_obj_conv.inner = (void*)(this_obj & (~1));
40678         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40680         RoutingFees_free(this_obj_conv);
40681 }
40682
40683 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
40684         LDKRoutingFees this_ptr_conv;
40685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40686         this_ptr_conv.is_owned = false;
40687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40688         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
40689         return ret_conv;
40690 }
40691
40692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40693         LDKRoutingFees this_ptr_conv;
40694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40695         this_ptr_conv.is_owned = false;
40696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40697         RoutingFees_set_base_msat(&this_ptr_conv, val);
40698 }
40699
40700 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
40701         LDKRoutingFees this_ptr_conv;
40702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40703         this_ptr_conv.is_owned = false;
40704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40705         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
40706         return ret_conv;
40707 }
40708
40709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40710         LDKRoutingFees this_ptr_conv;
40711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40712         this_ptr_conv.is_owned = false;
40713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40714         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
40715 }
40716
40717 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) {
40718         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
40719         int64_t ret_ref = 0;
40720         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40721         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40723         ret_ref = (uintptr_t)ret_var.inner;
40724         if (ret_var.is_owned) {
40725                 ret_ref |= 1;
40726         }
40727         return ret_ref;
40728 }
40729
40730 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
40731         LDKRoutingFees a_conv;
40732         a_conv.inner = (void*)(a & (~1));
40733         a_conv.is_owned = false;
40734         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40735         LDKRoutingFees b_conv;
40736         b_conv.inner = (void*)(b & (~1));
40737         b_conv.is_owned = false;
40738         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40739         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
40740         return ret_conv;
40741 }
40742
40743 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
40744         LDKRoutingFees ret_var = RoutingFees_clone(arg);
40745 int64_t ret_ref = 0;
40746 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40747 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40748 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40749 ret_ref = (uintptr_t)ret_var.inner;
40750 if (ret_var.is_owned) {
40751         ret_ref |= 1;
40752 }
40753         return ret_ref;
40754 }
40755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40756         LDKRoutingFees arg_conv;
40757         arg_conv.inner = (void*)(arg & (~1));
40758         arg_conv.is_owned = false;
40759         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40760         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
40761         return ret_conv;
40762 }
40763
40764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40765         LDKRoutingFees orig_conv;
40766         orig_conv.inner = (void*)(orig & (~1));
40767         orig_conv.is_owned = false;
40768         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40769         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
40770         int64_t ret_ref = 0;
40771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40774         ret_ref = (uintptr_t)ret_var.inner;
40775         if (ret_var.is_owned) {
40776                 ret_ref |= 1;
40777         }
40778         return ret_ref;
40779 }
40780
40781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
40782         LDKRoutingFees o_conv;
40783         o_conv.inner = (void*)(o & (~1));
40784         o_conv.is_owned = false;
40785         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40786         int64_t ret_conv = RoutingFees_hash(&o_conv);
40787         return ret_conv;
40788 }
40789
40790 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
40791         LDKRoutingFees obj_conv;
40792         obj_conv.inner = (void*)(obj & (~1));
40793         obj_conv.is_owned = false;
40794         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40795         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
40796         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40797         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40798         CVec_u8Z_free(ret_var);
40799         return ret_arr;
40800 }
40801
40802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40803         LDKu8slice ser_ref;
40804         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40805         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40806         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
40807         *ret_conv = RoutingFees_read(ser_ref);
40808         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40809         return (int64_t)ret_conv;
40810 }
40811
40812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40813         LDKNodeAnnouncementInfo this_obj_conv;
40814         this_obj_conv.inner = (void*)(this_obj & (~1));
40815         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40817         NodeAnnouncementInfo_free(this_obj_conv);
40818 }
40819
40820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
40821         LDKNodeAnnouncementInfo this_ptr_conv;
40822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40823         this_ptr_conv.is_owned = false;
40824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40825         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
40826         int64_t ret_ref = 0;
40827         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40828         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40830         ret_ref = (uintptr_t)ret_var.inner;
40831         if (ret_var.is_owned) {
40832                 ret_ref |= 1;
40833         }
40834         return ret_ref;
40835 }
40836
40837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40838         LDKNodeAnnouncementInfo this_ptr_conv;
40839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40840         this_ptr_conv.is_owned = false;
40841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40842         LDKNodeFeatures val_conv;
40843         val_conv.inner = (void*)(val & (~1));
40844         val_conv.is_owned = (val & 1) || (val == 0);
40845         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40846         val_conv = NodeFeatures_clone(&val_conv);
40847         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
40848 }
40849
40850 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
40851         LDKNodeAnnouncementInfo this_ptr_conv;
40852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40853         this_ptr_conv.is_owned = false;
40854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40855         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
40856         return ret_conv;
40857 }
40858
40859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
40860         LDKNodeAnnouncementInfo this_ptr_conv;
40861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40862         this_ptr_conv.is_owned = false;
40863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40864         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
40865 }
40866
40867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
40868         LDKNodeAnnouncementInfo this_ptr_conv;
40869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40870         this_ptr_conv.is_owned = false;
40871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40872         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
40873         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
40874         return ret_arr;
40875 }
40876
40877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40878         LDKNodeAnnouncementInfo this_ptr_conv;
40879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40880         this_ptr_conv.is_owned = false;
40881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40882         LDKThreeBytes val_ref;
40883         CHECK((*env)->GetArrayLength(env, val) == 3);
40884         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
40885         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
40886 }
40887
40888 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
40889         LDKNodeAnnouncementInfo this_ptr_conv;
40890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40891         this_ptr_conv.is_owned = false;
40892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40893         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40894         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
40895         return ret_arr;
40896 }
40897
40898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40899         LDKNodeAnnouncementInfo this_ptr_conv;
40900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40901         this_ptr_conv.is_owned = false;
40902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40903         LDKThirtyTwoBytes val_ref;
40904         CHECK((*env)->GetArrayLength(env, val) == 32);
40905         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40906         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
40907 }
40908
40909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
40910         LDKNodeAnnouncementInfo this_ptr_conv;
40911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40912         this_ptr_conv.is_owned = false;
40913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40914         LDKCVec_NetAddressZ val_constr;
40915         val_constr.datalen = (*env)->GetArrayLength(env, val);
40916         if (val_constr.datalen > 0)
40917                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40918         else
40919                 val_constr.data = NULL;
40920         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
40921         for (size_t m = 0; m < val_constr.datalen; m++) {
40922                 int64_t val_conv_12 = val_vals[m];
40923                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
40924                 CHECK_ACCESS(val_conv_12_ptr);
40925                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
40926                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
40927                 val_constr.data[m] = val_conv_12_conv;
40928         }
40929         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
40930         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
40931 }
40932
40933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
40934         LDKNodeAnnouncementInfo this_ptr_conv;
40935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40936         this_ptr_conv.is_owned = false;
40937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40938         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
40939         int64_t ret_ref = 0;
40940         if ((uintptr_t)ret_var.inner > 4096) {
40941                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40942                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40944                 ret_ref = (uintptr_t)ret_var.inner;
40945                 if (ret_var.is_owned) {
40946                         ret_ref |= 1;
40947                 }
40948         }
40949         return ret_ref;
40950 }
40951
40952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40953         LDKNodeAnnouncementInfo this_ptr_conv;
40954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40955         this_ptr_conv.is_owned = false;
40956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40957         LDKNodeAnnouncement val_conv;
40958         val_conv.inner = (void*)(val & (~1));
40959         val_conv.is_owned = (val & 1) || (val == 0);
40960         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40961         val_conv = NodeAnnouncement_clone(&val_conv);
40962         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
40963 }
40964
40965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int8_tArray alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
40966         LDKNodeFeatures features_arg_conv;
40967         features_arg_conv.inner = (void*)(features_arg & (~1));
40968         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
40969         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
40970         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
40971         LDKThreeBytes rgb_arg_ref;
40972         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
40973         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
40974         LDKThirtyTwoBytes alias_arg_ref;
40975         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
40976         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
40977         LDKCVec_NetAddressZ addresses_arg_constr;
40978         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
40979         if (addresses_arg_constr.datalen > 0)
40980                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
40981         else
40982                 addresses_arg_constr.data = NULL;
40983         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
40984         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
40985                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
40986                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
40987                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
40988                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
40989                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
40990         }
40991         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
40992         LDKNodeAnnouncement announcement_message_arg_conv;
40993         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
40994         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
40995         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
40996         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
40997         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
40998         int64_t ret_ref = 0;
40999         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41000         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41002         ret_ref = (uintptr_t)ret_var.inner;
41003         if (ret_var.is_owned) {
41004                 ret_ref |= 1;
41005         }
41006         return ret_ref;
41007 }
41008
41009 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
41010         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
41011 int64_t ret_ref = 0;
41012 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41013 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41014 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41015 ret_ref = (uintptr_t)ret_var.inner;
41016 if (ret_var.is_owned) {
41017         ret_ref |= 1;
41018 }
41019         return ret_ref;
41020 }
41021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41022         LDKNodeAnnouncementInfo arg_conv;
41023         arg_conv.inner = (void*)(arg & (~1));
41024         arg_conv.is_owned = false;
41025         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41026         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
41027         return ret_conv;
41028 }
41029
41030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41031         LDKNodeAnnouncementInfo orig_conv;
41032         orig_conv.inner = (void*)(orig & (~1));
41033         orig_conv.is_owned = false;
41034         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41035         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
41036         int64_t ret_ref = 0;
41037         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41038         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41040         ret_ref = (uintptr_t)ret_var.inner;
41041         if (ret_var.is_owned) {
41042                 ret_ref |= 1;
41043         }
41044         return ret_ref;
41045 }
41046
41047 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
41048         LDKNodeAnnouncementInfo obj_conv;
41049         obj_conv.inner = (void*)(obj & (~1));
41050         obj_conv.is_owned = false;
41051         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41052         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
41053         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41054         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41055         CVec_u8Z_free(ret_var);
41056         return ret_arr;
41057 }
41058
41059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41060         LDKu8slice ser_ref;
41061         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41062         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41063         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
41064         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
41065         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41066         return (int64_t)ret_conv;
41067 }
41068
41069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41070         LDKNodeInfo this_obj_conv;
41071         this_obj_conv.inner = (void*)(this_obj & (~1));
41072         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41074         NodeInfo_free(this_obj_conv);
41075 }
41076
41077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
41078         LDKNodeInfo this_ptr_conv;
41079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41080         this_ptr_conv.is_owned = false;
41081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41082         LDKCVec_u64Z val_constr;
41083         val_constr.datalen = (*env)->GetArrayLength(env, val);
41084         if (val_constr.datalen > 0)
41085                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
41086         else
41087                 val_constr.data = NULL;
41088         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
41089         for (size_t g = 0; g < val_constr.datalen; g++) {
41090                 int64_t val_conv_6 = val_vals[g];
41091                 val_constr.data[g] = val_conv_6;
41092         }
41093         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
41094         NodeInfo_set_channels(&this_ptr_conv, val_constr);
41095 }
41096
41097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
41098         LDKNodeInfo this_ptr_conv;
41099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41100         this_ptr_conv.is_owned = false;
41101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41102         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
41103         int64_t ret_ref = 0;
41104         if ((uintptr_t)ret_var.inner > 4096) {
41105                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41106                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41108                 ret_ref = (uintptr_t)ret_var.inner;
41109                 if (ret_var.is_owned) {
41110                         ret_ref |= 1;
41111                 }
41112         }
41113         return ret_ref;
41114 }
41115
41116 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) {
41117         LDKNodeInfo this_ptr_conv;
41118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41119         this_ptr_conv.is_owned = false;
41120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41121         LDKRoutingFees val_conv;
41122         val_conv.inner = (void*)(val & (~1));
41123         val_conv.is_owned = (val & 1) || (val == 0);
41124         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41125         val_conv = RoutingFees_clone(&val_conv);
41126         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
41127 }
41128
41129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
41130         LDKNodeInfo this_ptr_conv;
41131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41132         this_ptr_conv.is_owned = false;
41133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41134         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
41135         int64_t ret_ref = 0;
41136         if ((uintptr_t)ret_var.inner > 4096) {
41137                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41138                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41140                 ret_ref = (uintptr_t)ret_var.inner;
41141                 if (ret_var.is_owned) {
41142                         ret_ref |= 1;
41143                 }
41144         }
41145         return ret_ref;
41146 }
41147
41148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41149         LDKNodeInfo this_ptr_conv;
41150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41151         this_ptr_conv.is_owned = false;
41152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41153         LDKNodeAnnouncementInfo val_conv;
41154         val_conv.inner = (void*)(val & (~1));
41155         val_conv.is_owned = (val & 1) || (val == 0);
41156         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41157         val_conv = NodeAnnouncementInfo_clone(&val_conv);
41158         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
41159 }
41160
41161 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) {
41162         LDKCVec_u64Z channels_arg_constr;
41163         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
41164         if (channels_arg_constr.datalen > 0)
41165                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
41166         else
41167                 channels_arg_constr.data = NULL;
41168         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
41169         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
41170                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
41171                 channels_arg_constr.data[g] = channels_arg_conv_6;
41172         }
41173         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
41174         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
41175         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
41176         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
41177         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
41178         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
41179         LDKNodeAnnouncementInfo announcement_info_arg_conv;
41180         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
41181         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
41182         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
41183         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
41184         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
41185         int64_t ret_ref = 0;
41186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41189         ret_ref = (uintptr_t)ret_var.inner;
41190         if (ret_var.is_owned) {
41191                 ret_ref |= 1;
41192         }
41193         return ret_ref;
41194 }
41195
41196 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
41197         LDKNodeInfo ret_var = NodeInfo_clone(arg);
41198 int64_t ret_ref = 0;
41199 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41200 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41201 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41202 ret_ref = (uintptr_t)ret_var.inner;
41203 if (ret_var.is_owned) {
41204         ret_ref |= 1;
41205 }
41206         return ret_ref;
41207 }
41208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41209         LDKNodeInfo arg_conv;
41210         arg_conv.inner = (void*)(arg & (~1));
41211         arg_conv.is_owned = false;
41212         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41213         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
41214         return ret_conv;
41215 }
41216
41217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41218         LDKNodeInfo orig_conv;
41219         orig_conv.inner = (void*)(orig & (~1));
41220         orig_conv.is_owned = false;
41221         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41222         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
41223         int64_t ret_ref = 0;
41224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41227         ret_ref = (uintptr_t)ret_var.inner;
41228         if (ret_var.is_owned) {
41229                 ret_ref |= 1;
41230         }
41231         return ret_ref;
41232 }
41233
41234 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
41235         LDKNodeInfo obj_conv;
41236         obj_conv.inner = (void*)(obj & (~1));
41237         obj_conv.is_owned = false;
41238         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41239         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
41240         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41241         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41242         CVec_u8Z_free(ret_var);
41243         return ret_arr;
41244 }
41245
41246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41247         LDKu8slice ser_ref;
41248         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41249         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41250         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
41251         *ret_conv = NodeInfo_read(ser_ref);
41252         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41253         return (int64_t)ret_conv;
41254 }
41255
41256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
41257         LDKNetworkGraph obj_conv;
41258         obj_conv.inner = (void*)(obj & (~1));
41259         obj_conv.is_owned = false;
41260         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41261         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
41262         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41263         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41264         CVec_u8Z_free(ret_var);
41265         return ret_arr;
41266 }
41267
41268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41269         LDKu8slice ser_ref;
41270         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41271         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41272         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
41273         *ret_conv = NetworkGraph_read(ser_ref);
41274         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41275         return (int64_t)ret_conv;
41276 }
41277
41278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
41279         LDKThirtyTwoBytes genesis_hash_ref;
41280         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
41281         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
41282         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
41283         int64_t ret_ref = 0;
41284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41287         ret_ref = (uintptr_t)ret_var.inner;
41288         if (ret_var.is_owned) {
41289                 ret_ref |= 1;
41290         }
41291         return ret_ref;
41292 }
41293
41294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
41295         LDKNetworkGraph this_arg_conv;
41296         this_arg_conv.inner = (void*)(this_arg & (~1));
41297         this_arg_conv.is_owned = false;
41298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41299         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
41300         int64_t ret_ref = 0;
41301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41304         ret_ref = (uintptr_t)ret_var.inner;
41305         if (ret_var.is_owned) {
41306                 ret_ref |= 1;
41307         }
41308         return ret_ref;
41309 }
41310
41311 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) {
41312         LDKNetworkGraph 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         LDKNodeAnnouncement msg_conv;
41317         msg_conv.inner = (void*)(msg & (~1));
41318         msg_conv.is_owned = false;
41319         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41320         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41321         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
41322         return (int64_t)ret_conv;
41323 }
41324
41325 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) {
41326         LDKNetworkGraph this_arg_conv;
41327         this_arg_conv.inner = (void*)(this_arg & (~1));
41328         this_arg_conv.is_owned = false;
41329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41330         LDKUnsignedNodeAnnouncement msg_conv;
41331         msg_conv.inner = (void*)(msg & (~1));
41332         msg_conv.is_owned = false;
41333         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41334         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41335         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
41336         return (int64_t)ret_conv;
41337 }
41338
41339 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) {
41340         LDKNetworkGraph this_arg_conv;
41341         this_arg_conv.inner = (void*)(this_arg & (~1));
41342         this_arg_conv.is_owned = false;
41343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41344         LDKChannelAnnouncement msg_conv;
41345         msg_conv.inner = (void*)(msg & (~1));
41346         msg_conv.is_owned = false;
41347         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41348         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41349         CHECK_ACCESS(chain_access_ptr);
41350         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41351         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41352         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41353                 // Manually implement clone for Java trait instances
41354                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41355                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41356                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41357                 }
41358         }
41359         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41360         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
41361         return (int64_t)ret_conv;
41362 }
41363
41364 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) {
41365         LDKNetworkGraph this_arg_conv;
41366         this_arg_conv.inner = (void*)(this_arg & (~1));
41367         this_arg_conv.is_owned = false;
41368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41369         LDKUnsignedChannelAnnouncement msg_conv;
41370         msg_conv.inner = (void*)(msg & (~1));
41371         msg_conv.is_owned = false;
41372         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41373         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
41374         CHECK_ACCESS(chain_access_ptr);
41375         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
41376         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
41377         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
41378                 // Manually implement clone for Java trait instances
41379                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
41380                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41381                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
41382                 }
41383         }
41384         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41385         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
41386         return (int64_t)ret_conv;
41387 }
41388
41389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1close_1channel_1from_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
41390         LDKNetworkGraph this_arg_conv;
41391         this_arg_conv.inner = (void*)(this_arg & (~1));
41392         this_arg_conv.is_owned = false;
41393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41394         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
41395 }
41396
41397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1fail_1node(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
41398         LDKNetworkGraph this_arg_conv;
41399         this_arg_conv.inner = (void*)(this_arg & (~1));
41400         this_arg_conv.is_owned = false;
41401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41402         LDKPublicKey _node_id_ref;
41403         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
41404         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
41405         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
41406 }
41407
41408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
41409         LDKNetworkGraph this_arg_conv;
41410         this_arg_conv.inner = (void*)(this_arg & (~1));
41411         this_arg_conv.is_owned = false;
41412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41413         NetworkGraph_remove_stale_channels(&this_arg_conv);
41414 }
41415
41416 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) {
41417         LDKNetworkGraph this_arg_conv;
41418         this_arg_conv.inner = (void*)(this_arg & (~1));
41419         this_arg_conv.is_owned = false;
41420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41421         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
41422 }
41423
41424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
41425         LDKNetworkGraph this_arg_conv;
41426         this_arg_conv.inner = (void*)(this_arg & (~1));
41427         this_arg_conv.is_owned = false;
41428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41429         LDKChannelUpdate msg_conv;
41430         msg_conv.inner = (void*)(msg & (~1));
41431         msg_conv.is_owned = false;
41432         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41433         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41434         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
41435         return (int64_t)ret_conv;
41436 }
41437
41438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
41439         LDKNetworkGraph 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         LDKUnsignedChannelUpdate msg_conv;
41444         msg_conv.inner = (void*)(msg & (~1));
41445         msg_conv.is_owned = false;
41446         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
41447         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
41448         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
41449         return (int64_t)ret_conv;
41450 }
41451
41452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
41453         LDKReadOnlyNetworkGraph this_arg_conv;
41454         this_arg_conv.inner = (void*)(this_arg & (~1));
41455         this_arg_conv.is_owned = false;
41456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41457         LDKPublicKey pubkey_ref;
41458         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
41459         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
41460         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
41461         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
41462         int64_t ret_ref = (uintptr_t)ret_copy;
41463         return ret_ref;
41464 }
41465
41466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41467         LDKRouteHop this_obj_conv;
41468         this_obj_conv.inner = (void*)(this_obj & (~1));
41469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41471         RouteHop_free(this_obj_conv);
41472 }
41473
41474 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
41475         LDKRouteHop this_ptr_conv;
41476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41477         this_ptr_conv.is_owned = false;
41478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41479         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41480         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
41481         return ret_arr;
41482 }
41483
41484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41485         LDKRouteHop this_ptr_conv;
41486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41487         this_ptr_conv.is_owned = false;
41488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41489         LDKPublicKey val_ref;
41490         CHECK((*env)->GetArrayLength(env, val) == 33);
41491         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41492         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
41493 }
41494
41495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
41496         LDKRouteHop this_ptr_conv;
41497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41498         this_ptr_conv.is_owned = false;
41499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41500         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
41501         int64_t ret_ref = 0;
41502         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41503         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41505         ret_ref = (uintptr_t)ret_var.inner;
41506         if (ret_var.is_owned) {
41507                 ret_ref |= 1;
41508         }
41509         return ret_ref;
41510 }
41511
41512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41513         LDKRouteHop this_ptr_conv;
41514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41515         this_ptr_conv.is_owned = false;
41516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41517         LDKNodeFeatures val_conv;
41518         val_conv.inner = (void*)(val & (~1));
41519         val_conv.is_owned = (val & 1) || (val == 0);
41520         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41521         val_conv = NodeFeatures_clone(&val_conv);
41522         RouteHop_set_node_features(&this_ptr_conv, val_conv);
41523 }
41524
41525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
41526         LDKRouteHop this_ptr_conv;
41527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41528         this_ptr_conv.is_owned = false;
41529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41530         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
41531         return ret_conv;
41532 }
41533
41534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41535         LDKRouteHop this_ptr_conv;
41536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41537         this_ptr_conv.is_owned = false;
41538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41539         RouteHop_set_short_channel_id(&this_ptr_conv, val);
41540 }
41541
41542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
41543         LDKRouteHop this_ptr_conv;
41544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41545         this_ptr_conv.is_owned = false;
41546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41547         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
41548         int64_t ret_ref = 0;
41549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41552         ret_ref = (uintptr_t)ret_var.inner;
41553         if (ret_var.is_owned) {
41554                 ret_ref |= 1;
41555         }
41556         return ret_ref;
41557 }
41558
41559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41560         LDKRouteHop this_ptr_conv;
41561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41562         this_ptr_conv.is_owned = false;
41563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41564         LDKChannelFeatures val_conv;
41565         val_conv.inner = (void*)(val & (~1));
41566         val_conv.is_owned = (val & 1) || (val == 0);
41567         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41568         val_conv = ChannelFeatures_clone(&val_conv);
41569         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
41570 }
41571
41572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
41573         LDKRouteHop this_ptr_conv;
41574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41575         this_ptr_conv.is_owned = false;
41576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41577         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
41578         return ret_conv;
41579 }
41580
41581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41582         LDKRouteHop this_ptr_conv;
41583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41584         this_ptr_conv.is_owned = false;
41585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41586         RouteHop_set_fee_msat(&this_ptr_conv, val);
41587 }
41588
41589 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
41590         LDKRouteHop this_ptr_conv;
41591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41592         this_ptr_conv.is_owned = false;
41593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41594         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
41595         return ret_conv;
41596 }
41597
41598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
41599         LDKRouteHop this_ptr_conv;
41600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41601         this_ptr_conv.is_owned = false;
41602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41603         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
41604 }
41605
41606 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) {
41607         LDKPublicKey pubkey_arg_ref;
41608         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
41609         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
41610         LDKNodeFeatures node_features_arg_conv;
41611         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
41612         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
41613         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
41614         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
41615         LDKChannelFeatures channel_features_arg_conv;
41616         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
41617         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
41618         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
41619         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
41620         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);
41621         int64_t ret_ref = 0;
41622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41625         ret_ref = (uintptr_t)ret_var.inner;
41626         if (ret_var.is_owned) {
41627                 ret_ref |= 1;
41628         }
41629         return ret_ref;
41630 }
41631
41632 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
41633         LDKRouteHop ret_var = RouteHop_clone(arg);
41634 int64_t ret_ref = 0;
41635 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41636 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41637 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41638 ret_ref = (uintptr_t)ret_var.inner;
41639 if (ret_var.is_owned) {
41640         ret_ref |= 1;
41641 }
41642         return ret_ref;
41643 }
41644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41645         LDKRouteHop arg_conv;
41646         arg_conv.inner = (void*)(arg & (~1));
41647         arg_conv.is_owned = false;
41648         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41649         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
41650         return ret_conv;
41651 }
41652
41653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41654         LDKRouteHop orig_conv;
41655         orig_conv.inner = (void*)(orig & (~1));
41656         orig_conv.is_owned = false;
41657         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41658         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
41659         int64_t ret_ref = 0;
41660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41663         ret_ref = (uintptr_t)ret_var.inner;
41664         if (ret_var.is_owned) {
41665                 ret_ref |= 1;
41666         }
41667         return ret_ref;
41668 }
41669
41670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
41671         LDKRouteHop o_conv;
41672         o_conv.inner = (void*)(o & (~1));
41673         o_conv.is_owned = false;
41674         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41675         int64_t ret_conv = RouteHop_hash(&o_conv);
41676         return ret_conv;
41677 }
41678
41679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41680         LDKRouteHop a_conv;
41681         a_conv.inner = (void*)(a & (~1));
41682         a_conv.is_owned = false;
41683         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41684         LDKRouteHop b_conv;
41685         b_conv.inner = (void*)(b & (~1));
41686         b_conv.is_owned = false;
41687         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41688         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
41689         return ret_conv;
41690 }
41691
41692 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
41693         LDKRouteHop obj_conv;
41694         obj_conv.inner = (void*)(obj & (~1));
41695         obj_conv.is_owned = false;
41696         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41697         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
41698         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41699         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41700         CVec_u8Z_free(ret_var);
41701         return ret_arr;
41702 }
41703
41704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41705         LDKu8slice ser_ref;
41706         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41707         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41708         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
41709         *ret_conv = RouteHop_read(ser_ref);
41710         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41711         return (int64_t)ret_conv;
41712 }
41713
41714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41715         LDKRoute this_obj_conv;
41716         this_obj_conv.inner = (void*)(this_obj & (~1));
41717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41719         Route_free(this_obj_conv);
41720 }
41721
41722 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
41723         LDKRoute this_ptr_conv;
41724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41725         this_ptr_conv.is_owned = false;
41726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41727         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
41728         jobjectArray ret_arr = NULL;
41729         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
41730         ;
41731         for (size_t m = 0; m < ret_var.datalen; m++) {
41732                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
41733                 int64_tArray ret_conv_12_arr = NULL;
41734                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
41735                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
41736                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
41737                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
41738                         int64_t ret_conv_12_conv_10_ref = 0;
41739                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41740                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41741                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
41742                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
41743                         if (ret_conv_12_conv_10_var.is_owned) {
41744                                 ret_conv_12_conv_10_ref |= 1;
41745                         }
41746                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
41747                 }
41748                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
41749                 FREE(ret_conv_12_var.data);
41750                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
41751         }
41752         
41753         FREE(ret_var.data);
41754         return ret_arr;
41755 }
41756
41757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
41758         LDKRoute this_ptr_conv;
41759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41760         this_ptr_conv.is_owned = false;
41761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41762         LDKCVec_CVec_RouteHopZZ val_constr;
41763         val_constr.datalen = (*env)->GetArrayLength(env, val);
41764         if (val_constr.datalen > 0)
41765                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41766         else
41767                 val_constr.data = NULL;
41768         for (size_t m = 0; m < val_constr.datalen; m++) {
41769                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
41770                 LDKCVec_RouteHopZ val_conv_12_constr;
41771                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
41772                 if (val_conv_12_constr.datalen > 0)
41773                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41774                 else
41775                         val_conv_12_constr.data = NULL;
41776                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
41777                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
41778                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
41779                         LDKRouteHop val_conv_12_conv_10_conv;
41780                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
41781                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
41782                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
41783                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
41784                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
41785                 }
41786                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
41787                 val_constr.data[m] = val_conv_12_constr;
41788         }
41789         Route_set_paths(&this_ptr_conv, val_constr);
41790 }
41791
41792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
41793         LDKRoute this_ptr_conv;
41794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41795         this_ptr_conv.is_owned = false;
41796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41797         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
41798         int64_t ret_ref = 0;
41799         if ((uintptr_t)ret_var.inner > 4096) {
41800                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41801                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41803                 ret_ref = (uintptr_t)ret_var.inner;
41804                 if (ret_var.is_owned) {
41805                         ret_ref |= 1;
41806                 }
41807         }
41808         return ret_ref;
41809 }
41810
41811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41812         LDKRoute this_ptr_conv;
41813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41814         this_ptr_conv.is_owned = false;
41815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41816         LDKPaymentParameters val_conv;
41817         val_conv.inner = (void*)(val & (~1));
41818         val_conv.is_owned = (val & 1) || (val == 0);
41819         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41820         val_conv = PaymentParameters_clone(&val_conv);
41821         Route_set_payment_params(&this_ptr_conv, val_conv);
41822 }
41823
41824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
41825         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
41826         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
41827         if (paths_arg_constr.datalen > 0)
41828                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
41829         else
41830                 paths_arg_constr.data = NULL;
41831         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
41832                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
41833                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
41834                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
41835                 if (paths_arg_conv_12_constr.datalen > 0)
41836                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
41837                 else
41838                         paths_arg_conv_12_constr.data = NULL;
41839                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
41840                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
41841                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
41842                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
41843                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
41844                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
41845                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
41846                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
41847                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
41848                 }
41849                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
41850                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
41851         }
41852         LDKPaymentParameters payment_params_arg_conv;
41853         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
41854         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
41855         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
41856         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
41857         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
41858         int64_t ret_ref = 0;
41859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41862         ret_ref = (uintptr_t)ret_var.inner;
41863         if (ret_var.is_owned) {
41864                 ret_ref |= 1;
41865         }
41866         return ret_ref;
41867 }
41868
41869 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
41870         LDKRoute ret_var = Route_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41882         LDKRoute arg_conv;
41883         arg_conv.inner = (void*)(arg & (~1));
41884         arg_conv.is_owned = false;
41885         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41886         int64_t ret_conv = Route_clone_ptr(&arg_conv);
41887         return ret_conv;
41888 }
41889
41890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41891         LDKRoute orig_conv;
41892         orig_conv.inner = (void*)(orig & (~1));
41893         orig_conv.is_owned = false;
41894         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41895         LDKRoute ret_var = Route_clone(&orig_conv);
41896         int64_t ret_ref = 0;
41897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41900         ret_ref = (uintptr_t)ret_var.inner;
41901         if (ret_var.is_owned) {
41902                 ret_ref |= 1;
41903         }
41904         return ret_ref;
41905 }
41906
41907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
41908         LDKRoute o_conv;
41909         o_conv.inner = (void*)(o & (~1));
41910         o_conv.is_owned = false;
41911         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41912         int64_t ret_conv = Route_hash(&o_conv);
41913         return ret_conv;
41914 }
41915
41916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41917         LDKRoute a_conv;
41918         a_conv.inner = (void*)(a & (~1));
41919         a_conv.is_owned = false;
41920         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41921         LDKRoute b_conv;
41922         b_conv.inner = (void*)(b & (~1));
41923         b_conv.is_owned = false;
41924         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41925         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
41926         return ret_conv;
41927 }
41928
41929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
41930         LDKRoute this_arg_conv;
41931         this_arg_conv.inner = (void*)(this_arg & (~1));
41932         this_arg_conv.is_owned = false;
41933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41934         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
41935         return ret_conv;
41936 }
41937
41938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
41939         LDKRoute this_arg_conv;
41940         this_arg_conv.inner = (void*)(this_arg & (~1));
41941         this_arg_conv.is_owned = false;
41942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41943         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
41944         return ret_conv;
41945 }
41946
41947 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
41948         LDKRoute obj_conv;
41949         obj_conv.inner = (void*)(obj & (~1));
41950         obj_conv.is_owned = false;
41951         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41952         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
41953         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41954         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41955         CVec_u8Z_free(ret_var);
41956         return ret_arr;
41957 }
41958
41959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41960         LDKu8slice ser_ref;
41961         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41962         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41963         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
41964         *ret_conv = Route_read(ser_ref);
41965         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41966         return (int64_t)ret_conv;
41967 }
41968
41969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41970         LDKRouteParameters 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         RouteParameters_free(this_obj_conv);
41975 }
41976
41977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
41978         LDKRouteParameters this_ptr_conv;
41979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41980         this_ptr_conv.is_owned = false;
41981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41982         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
41983         int64_t ret_ref = 0;
41984         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41985         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41987         ret_ref = (uintptr_t)ret_var.inner;
41988         if (ret_var.is_owned) {
41989                 ret_ref |= 1;
41990         }
41991         return ret_ref;
41992 }
41993
41994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
41995         LDKRouteParameters this_ptr_conv;
41996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41997         this_ptr_conv.is_owned = false;
41998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41999         LDKPaymentParameters val_conv;
42000         val_conv.inner = (void*)(val & (~1));
42001         val_conv.is_owned = (val & 1) || (val == 0);
42002         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42003         val_conv = PaymentParameters_clone(&val_conv);
42004         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
42005 }
42006
42007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42008         LDKRouteParameters this_ptr_conv;
42009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42010         this_ptr_conv.is_owned = false;
42011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42012         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
42013         return ret_conv;
42014 }
42015
42016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42017         LDKRouteParameters this_ptr_conv;
42018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42019         this_ptr_conv.is_owned = false;
42020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42021         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
42022 }
42023
42024 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
42025         LDKRouteParameters this_ptr_conv;
42026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42027         this_ptr_conv.is_owned = false;
42028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42029         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
42030         return ret_conv;
42031 }
42032
42033 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) {
42034         LDKRouteParameters this_ptr_conv;
42035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42036         this_ptr_conv.is_owned = false;
42037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42038         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
42039 }
42040
42041 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) {
42042         LDKPaymentParameters payment_params_arg_conv;
42043         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
42044         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
42045         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
42046         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
42047         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
42048         int64_t ret_ref = 0;
42049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42052         ret_ref = (uintptr_t)ret_var.inner;
42053         if (ret_var.is_owned) {
42054                 ret_ref |= 1;
42055         }
42056         return ret_ref;
42057 }
42058
42059 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
42060         LDKRouteParameters ret_var = RouteParameters_clone(arg);
42061 int64_t ret_ref = 0;
42062 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42063 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42064 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42065 ret_ref = (uintptr_t)ret_var.inner;
42066 if (ret_var.is_owned) {
42067         ret_ref |= 1;
42068 }
42069         return ret_ref;
42070 }
42071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42072         LDKRouteParameters arg_conv;
42073         arg_conv.inner = (void*)(arg & (~1));
42074         arg_conv.is_owned = false;
42075         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42076         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
42077         return ret_conv;
42078 }
42079
42080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42081         LDKRouteParameters orig_conv;
42082         orig_conv.inner = (void*)(orig & (~1));
42083         orig_conv.is_owned = false;
42084         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42085         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
42086         int64_t ret_ref = 0;
42087         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42088         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42090         ret_ref = (uintptr_t)ret_var.inner;
42091         if (ret_var.is_owned) {
42092                 ret_ref |= 1;
42093         }
42094         return ret_ref;
42095 }
42096
42097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42098         LDKRouteParameters obj_conv;
42099         obj_conv.inner = (void*)(obj & (~1));
42100         obj_conv.is_owned = false;
42101         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42102         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
42103         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42104         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42105         CVec_u8Z_free(ret_var);
42106         return ret_arr;
42107 }
42108
42109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42110         LDKu8slice ser_ref;
42111         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42112         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42113         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
42114         *ret_conv = RouteParameters_read(ser_ref);
42115         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42116         return (int64_t)ret_conv;
42117 }
42118
42119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42120         LDKPaymentParameters this_obj_conv;
42121         this_obj_conv.inner = (void*)(this_obj & (~1));
42122         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42124         PaymentParameters_free(this_obj_conv);
42125 }
42126
42127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
42128         LDKPaymentParameters this_ptr_conv;
42129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42130         this_ptr_conv.is_owned = false;
42131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42132         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42133         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
42134         return ret_arr;
42135 }
42136
42137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42138         LDKPaymentParameters this_ptr_conv;
42139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42140         this_ptr_conv.is_owned = false;
42141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42142         LDKPublicKey val_ref;
42143         CHECK((*env)->GetArrayLength(env, val) == 33);
42144         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42145         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
42146 }
42147
42148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
42149         LDKPaymentParameters this_ptr_conv;
42150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42151         this_ptr_conv.is_owned = false;
42152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42153         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
42154         int64_t ret_ref = 0;
42155         if ((uintptr_t)ret_var.inner > 4096) {
42156                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42157                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42159                 ret_ref = (uintptr_t)ret_var.inner;
42160                 if (ret_var.is_owned) {
42161                         ret_ref |= 1;
42162                 }
42163         }
42164         return ret_ref;
42165 }
42166
42167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42168         LDKPaymentParameters this_ptr_conv;
42169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42170         this_ptr_conv.is_owned = false;
42171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42172         LDKInvoiceFeatures val_conv;
42173         val_conv.inner = (void*)(val & (~1));
42174         val_conv.is_owned = (val & 1) || (val == 0);
42175         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42176         val_conv = InvoiceFeatures_clone(&val_conv);
42177         PaymentParameters_set_features(&this_ptr_conv, val_conv);
42178 }
42179
42180 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
42181         LDKPaymentParameters this_ptr_conv;
42182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42183         this_ptr_conv.is_owned = false;
42184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42185         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
42186         int64_tArray ret_arr = NULL;
42187         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
42188         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
42189         for (size_t l = 0; l < ret_var.datalen; l++) {
42190                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
42191                 int64_t ret_conv_11_ref = 0;
42192                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42193                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42194                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
42195                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
42196                 if (ret_conv_11_var.is_owned) {
42197                         ret_conv_11_ref |= 1;
42198                 }
42199                 ret_arr_ptr[l] = ret_conv_11_ref;
42200         }
42201         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42202         FREE(ret_var.data);
42203         return ret_arr;
42204 }
42205
42206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
42207         LDKPaymentParameters this_ptr_conv;
42208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42209         this_ptr_conv.is_owned = false;
42210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42211         LDKCVec_RouteHintZ val_constr;
42212         val_constr.datalen = (*env)->GetArrayLength(env, val);
42213         if (val_constr.datalen > 0)
42214                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
42215         else
42216                 val_constr.data = NULL;
42217         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
42218         for (size_t l = 0; l < val_constr.datalen; l++) {
42219                 int64_t val_conv_11 = val_vals[l];
42220                 LDKRouteHint val_conv_11_conv;
42221                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
42222                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
42223                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
42224                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
42225                 val_constr.data[l] = val_conv_11_conv;
42226         }
42227         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
42228         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
42229 }
42230
42231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
42232         LDKPaymentParameters this_ptr_conv;
42233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42234         this_ptr_conv.is_owned = false;
42235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42236         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42237         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
42238         int64_t ret_ref = (uintptr_t)ret_copy;
42239         return ret_ref;
42240 }
42241
42242 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42243         LDKPaymentParameters this_ptr_conv;
42244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42245         this_ptr_conv.is_owned = false;
42246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42247         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42248         CHECK_ACCESS(val_ptr);
42249         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42250         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42251         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
42252 }
42253
42254 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
42255         LDKPaymentParameters this_ptr_conv;
42256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42257         this_ptr_conv.is_owned = false;
42258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42259         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
42260         return ret_conv;
42261 }
42262
42263 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) {
42264         LDKPaymentParameters this_ptr_conv;
42265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42266         this_ptr_conv.is_owned = false;
42267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42268         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
42269 }
42270
42271 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) {
42272         LDKPublicKey payee_pubkey_arg_ref;
42273         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
42274         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
42275         LDKInvoiceFeatures features_arg_conv;
42276         features_arg_conv.inner = (void*)(features_arg & (~1));
42277         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
42278         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
42279         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
42280         LDKCVec_RouteHintZ route_hints_arg_constr;
42281         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
42282         if (route_hints_arg_constr.datalen > 0)
42283                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
42284         else
42285                 route_hints_arg_constr.data = NULL;
42286         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
42287         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
42288                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
42289                 LDKRouteHint route_hints_arg_conv_11_conv;
42290                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
42291                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
42292                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
42293                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
42294                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
42295         }
42296         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
42297         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
42298         CHECK_ACCESS(expiry_time_arg_ptr);
42299         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
42300         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
42301         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);
42302         int64_t ret_ref = 0;
42303         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42304         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42306         ret_ref = (uintptr_t)ret_var.inner;
42307         if (ret_var.is_owned) {
42308                 ret_ref |= 1;
42309         }
42310         return ret_ref;
42311 }
42312
42313 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
42314         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
42315 int64_t ret_ref = 0;
42316 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42317 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42318 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42319 ret_ref = (uintptr_t)ret_var.inner;
42320 if (ret_var.is_owned) {
42321         ret_ref |= 1;
42322 }
42323         return ret_ref;
42324 }
42325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42326         LDKPaymentParameters arg_conv;
42327         arg_conv.inner = (void*)(arg & (~1));
42328         arg_conv.is_owned = false;
42329         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42330         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
42331         return ret_conv;
42332 }
42333
42334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42335         LDKPaymentParameters orig_conv;
42336         orig_conv.inner = (void*)(orig & (~1));
42337         orig_conv.is_owned = false;
42338         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42339         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
42340         int64_t ret_ref = 0;
42341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42344         ret_ref = (uintptr_t)ret_var.inner;
42345         if (ret_var.is_owned) {
42346                 ret_ref |= 1;
42347         }
42348         return ret_ref;
42349 }
42350
42351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
42352         LDKPaymentParameters o_conv;
42353         o_conv.inner = (void*)(o & (~1));
42354         o_conv.is_owned = false;
42355         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42356         int64_t ret_conv = PaymentParameters_hash(&o_conv);
42357         return ret_conv;
42358 }
42359
42360 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42361         LDKPaymentParameters a_conv;
42362         a_conv.inner = (void*)(a & (~1));
42363         a_conv.is_owned = false;
42364         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42365         LDKPaymentParameters b_conv;
42366         b_conv.inner = (void*)(b & (~1));
42367         b_conv.is_owned = false;
42368         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42369         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
42370         return ret_conv;
42371 }
42372
42373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42374         LDKPaymentParameters obj_conv;
42375         obj_conv.inner = (void*)(obj & (~1));
42376         obj_conv.is_owned = false;
42377         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42378         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
42379         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42380         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42381         CVec_u8Z_free(ret_var);
42382         return ret_arr;
42383 }
42384
42385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42386         LDKu8slice ser_ref;
42387         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42388         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42389         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
42390         *ret_conv = PaymentParameters_read(ser_ref);
42391         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42392         return (int64_t)ret_conv;
42393 }
42394
42395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
42396         LDKPublicKey payee_pubkey_ref;
42397         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
42398         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
42399         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
42400         int64_t ret_ref = 0;
42401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42404         ret_ref = (uintptr_t)ret_var.inner;
42405         if (ret_var.is_owned) {
42406                 ret_ref |= 1;
42407         }
42408         return ret_ref;
42409 }
42410
42411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
42412         LDKPublicKey payee_pubkey_ref;
42413         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
42414         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
42415         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
42416         int64_t ret_ref = 0;
42417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42420         ret_ref = (uintptr_t)ret_var.inner;
42421         if (ret_var.is_owned) {
42422                 ret_ref |= 1;
42423         }
42424         return ret_ref;
42425 }
42426
42427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42428         LDKRouteHint this_obj_conv;
42429         this_obj_conv.inner = (void*)(this_obj & (~1));
42430         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42432         RouteHint_free(this_obj_conv);
42433 }
42434
42435 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
42436         LDKRouteHint this_ptr_conv;
42437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42438         this_ptr_conv.is_owned = false;
42439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42440         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
42441         int64_tArray ret_arr = NULL;
42442         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
42443         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
42444         for (size_t o = 0; o < ret_var.datalen; o++) {
42445                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
42446                 int64_t ret_conv_14_ref = 0;
42447                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42448                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42449                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
42450                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
42451                 if (ret_conv_14_var.is_owned) {
42452                         ret_conv_14_ref |= 1;
42453                 }
42454                 ret_arr_ptr[o] = ret_conv_14_ref;
42455         }
42456         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
42457         FREE(ret_var.data);
42458         return ret_arr;
42459 }
42460
42461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
42462         LDKRouteHint this_ptr_conv;
42463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42464         this_ptr_conv.is_owned = false;
42465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42466         LDKCVec_RouteHintHopZ val_constr;
42467         val_constr.datalen = (*env)->GetArrayLength(env, val);
42468         if (val_constr.datalen > 0)
42469                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42470         else
42471                 val_constr.data = NULL;
42472         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
42473         for (size_t o = 0; o < val_constr.datalen; o++) {
42474                 int64_t val_conv_14 = val_vals[o];
42475                 LDKRouteHintHop val_conv_14_conv;
42476                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
42477                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
42478                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
42479                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
42480                 val_constr.data[o] = val_conv_14_conv;
42481         }
42482         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
42483         RouteHint_set_a(&this_ptr_conv, val_constr);
42484 }
42485
42486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
42487         LDKCVec_RouteHintHopZ a_arg_constr;
42488         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
42489         if (a_arg_constr.datalen > 0)
42490                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
42491         else
42492                 a_arg_constr.data = NULL;
42493         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
42494         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
42495                 int64_t a_arg_conv_14 = a_arg_vals[o];
42496                 LDKRouteHintHop a_arg_conv_14_conv;
42497                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
42498                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
42499                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
42500                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
42501                 a_arg_constr.data[o] = a_arg_conv_14_conv;
42502         }
42503         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
42504         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
42505         int64_t ret_ref = 0;
42506         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42507         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42509         ret_ref = (uintptr_t)ret_var.inner;
42510         if (ret_var.is_owned) {
42511                 ret_ref |= 1;
42512         }
42513         return ret_ref;
42514 }
42515
42516 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
42517         LDKRouteHint ret_var = RouteHint_clone(arg);
42518 int64_t ret_ref = 0;
42519 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42520 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42521 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42522 ret_ref = (uintptr_t)ret_var.inner;
42523 if (ret_var.is_owned) {
42524         ret_ref |= 1;
42525 }
42526         return ret_ref;
42527 }
42528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42529         LDKRouteHint arg_conv;
42530         arg_conv.inner = (void*)(arg & (~1));
42531         arg_conv.is_owned = false;
42532         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42533         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
42534         return ret_conv;
42535 }
42536
42537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42538         LDKRouteHint orig_conv;
42539         orig_conv.inner = (void*)(orig & (~1));
42540         orig_conv.is_owned = false;
42541         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42542         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
42543         int64_t ret_ref = 0;
42544         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42545         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42547         ret_ref = (uintptr_t)ret_var.inner;
42548         if (ret_var.is_owned) {
42549                 ret_ref |= 1;
42550         }
42551         return ret_ref;
42552 }
42553
42554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
42555         LDKRouteHint o_conv;
42556         o_conv.inner = (void*)(o & (~1));
42557         o_conv.is_owned = false;
42558         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42559         int64_t ret_conv = RouteHint_hash(&o_conv);
42560         return ret_conv;
42561 }
42562
42563 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42564         LDKRouteHint a_conv;
42565         a_conv.inner = (void*)(a & (~1));
42566         a_conv.is_owned = false;
42567         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42568         LDKRouteHint b_conv;
42569         b_conv.inner = (void*)(b & (~1));
42570         b_conv.is_owned = false;
42571         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42572         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
42573         return ret_conv;
42574 }
42575
42576 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
42577         LDKRouteHint obj_conv;
42578         obj_conv.inner = (void*)(obj & (~1));
42579         obj_conv.is_owned = false;
42580         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42581         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
42582         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42583         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42584         CVec_u8Z_free(ret_var);
42585         return ret_arr;
42586 }
42587
42588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42589         LDKu8slice ser_ref;
42590         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42591         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42592         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
42593         *ret_conv = RouteHint_read(ser_ref);
42594         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42595         return (int64_t)ret_conv;
42596 }
42597
42598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42599         LDKRouteHintHop this_obj_conv;
42600         this_obj_conv.inner = (void*)(this_obj & (~1));
42601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42603         RouteHintHop_free(this_obj_conv);
42604 }
42605
42606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
42607         LDKRouteHintHop 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
42612         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
42613         return ret_arr;
42614 }
42615
42616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42617         LDKRouteHintHop this_ptr_conv;
42618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42619         this_ptr_conv.is_owned = false;
42620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42621         LDKPublicKey val_ref;
42622         CHECK((*env)->GetArrayLength(env, val) == 33);
42623         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
42624         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
42625 }
42626
42627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
42628         LDKRouteHintHop this_ptr_conv;
42629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42630         this_ptr_conv.is_owned = false;
42631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42632         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
42633         return ret_conv;
42634 }
42635
42636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42637         LDKRouteHintHop 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         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
42642 }
42643
42644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
42645         LDKRouteHintHop this_ptr_conv;
42646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42647         this_ptr_conv.is_owned = false;
42648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42649         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
42650         int64_t ret_ref = 0;
42651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42654         ret_ref = (uintptr_t)ret_var.inner;
42655         if (ret_var.is_owned) {
42656                 ret_ref |= 1;
42657         }
42658         return ret_ref;
42659 }
42660
42661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42662         LDKRouteHintHop this_ptr_conv;
42663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42664         this_ptr_conv.is_owned = false;
42665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42666         LDKRoutingFees val_conv;
42667         val_conv.inner = (void*)(val & (~1));
42668         val_conv.is_owned = (val & 1) || (val == 0);
42669         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42670         val_conv = RoutingFees_clone(&val_conv);
42671         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
42672 }
42673
42674 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
42675         LDKRouteHintHop this_ptr_conv;
42676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42677         this_ptr_conv.is_owned = false;
42678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42679         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
42680         return ret_conv;
42681 }
42682
42683 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
42684         LDKRouteHintHop this_ptr_conv;
42685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42686         this_ptr_conv.is_owned = false;
42687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42688         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
42689 }
42690
42691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42692         LDKRouteHintHop 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         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42697         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
42698         int64_t ret_ref = (uintptr_t)ret_copy;
42699         return ret_ref;
42700 }
42701
42702 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42703         LDKRouteHintHop this_ptr_conv;
42704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42705         this_ptr_conv.is_owned = false;
42706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42707         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42708         CHECK_ACCESS(val_ptr);
42709         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42710         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42711         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
42712 }
42713
42714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42715         LDKRouteHintHop this_ptr_conv;
42716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42717         this_ptr_conv.is_owned = false;
42718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42719         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
42720         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
42721         int64_t ret_ref = (uintptr_t)ret_copy;
42722         return ret_ref;
42723 }
42724
42725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42726         LDKRouteHintHop this_ptr_conv;
42727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42728         this_ptr_conv.is_owned = false;
42729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42730         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
42731         CHECK_ACCESS(val_ptr);
42732         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
42733         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
42734         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
42735 }
42736
42737 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) {
42738         LDKPublicKey src_node_id_arg_ref;
42739         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
42740         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
42741         LDKRoutingFees fees_arg_conv;
42742         fees_arg_conv.inner = (void*)(fees_arg & (~1));
42743         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
42744         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
42745         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
42746         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
42747         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
42748         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
42749         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
42750         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
42751         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
42752         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
42753         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
42754         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);
42755         int64_t ret_ref = 0;
42756         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42757         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42759         ret_ref = (uintptr_t)ret_var.inner;
42760         if (ret_var.is_owned) {
42761                 ret_ref |= 1;
42762         }
42763         return ret_ref;
42764 }
42765
42766 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
42767         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
42768 int64_t ret_ref = 0;
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         return ret_ref;
42777 }
42778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42779         LDKRouteHintHop arg_conv;
42780         arg_conv.inner = (void*)(arg & (~1));
42781         arg_conv.is_owned = false;
42782         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42783         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
42784         return ret_conv;
42785 }
42786
42787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42788         LDKRouteHintHop orig_conv;
42789         orig_conv.inner = (void*)(orig & (~1));
42790         orig_conv.is_owned = false;
42791         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42792         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
42793         int64_t ret_ref = 0;
42794         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42795         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42797         ret_ref = (uintptr_t)ret_var.inner;
42798         if (ret_var.is_owned) {
42799                 ret_ref |= 1;
42800         }
42801         return ret_ref;
42802 }
42803
42804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
42805         LDKRouteHintHop o_conv;
42806         o_conv.inner = (void*)(o & (~1));
42807         o_conv.is_owned = false;
42808         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42809         int64_t ret_conv = RouteHintHop_hash(&o_conv);
42810         return ret_conv;
42811 }
42812
42813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42814         LDKRouteHintHop a_conv;
42815         a_conv.inner = (void*)(a & (~1));
42816         a_conv.is_owned = false;
42817         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42818         LDKRouteHintHop b_conv;
42819         b_conv.inner = (void*)(b & (~1));
42820         b_conv.is_owned = false;
42821         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42822         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
42823         return ret_conv;
42824 }
42825
42826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
42827         LDKRouteHintHop obj_conv;
42828         obj_conv.inner = (void*)(obj & (~1));
42829         obj_conv.is_owned = false;
42830         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42831         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
42832         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42833         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42834         CVec_u8Z_free(ret_var);
42835         return ret_arr;
42836 }
42837
42838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42839         LDKu8slice ser_ref;
42840         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42841         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42842         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
42843         *ret_conv = RouteHintHop_read(ser_ref);
42844         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42845         return (int64_t)ret_conv;
42846 }
42847
42848 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, int64_tArray first_hops, int64_t logger, int64_t scorer, int8_tArray random_seed_bytes) {
42849         LDKPublicKey our_node_pubkey_ref;
42850         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
42851         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
42852         LDKRouteParameters route_params_conv;
42853         route_params_conv.inner = (void*)(route_params & (~1));
42854         route_params_conv.is_owned = false;
42855         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
42856         LDKNetworkGraph network_conv;
42857         network_conv.inner = (void*)(network & (~1));
42858         network_conv.is_owned = false;
42859         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
42860         LDKCVec_ChannelDetailsZ first_hops_constr;
42861         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
42862         if (first_hops != NULL) {
42863                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
42864                 if (first_hops_constr.datalen > 0)
42865                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
42866                 else
42867                         first_hops_constr.data = NULL;
42868                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
42869                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
42870                         int64_t first_hops_conv_16 = first_hops_vals[q];
42871                         LDKChannelDetails first_hops_conv_16_conv;
42872                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
42873                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
42874                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
42875                         first_hops_constr.data[q] = first_hops_conv_16_conv;
42876                 }
42877                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
42878                 first_hops_ptr = &first_hops_constr;
42879         }
42880         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42881         CHECK_ACCESS(logger_ptr);
42882         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42883         if (logger_conv.free == LDKLogger_JCalls_free) {
42884                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42885                 LDKLogger_JCalls_cloned(&logger_conv);
42886         }
42887         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
42888         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
42889         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
42890         unsigned char random_seed_bytes_arr[32];
42891         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
42892         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
42893         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
42894         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
42895         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
42896         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
42897         return (int64_t)ret_conv;
42898 }
42899
42900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42901         if ((this_ptr & 1) != 0) return;
42902         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42903         CHECK_ACCESS(this_ptr_ptr);
42904         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
42905         FREE((void*)this_ptr);
42906         Score_free(this_ptr_conv);
42907 }
42908
42909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
42910         if ((this_ptr & 1) != 0) return;
42911         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42912         CHECK_ACCESS(this_ptr_ptr);
42913         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
42914         FREE((void*)this_ptr);
42915         LockableScore_free(this_ptr_conv);
42916 }
42917
42918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42919         LDKMultiThreadedLockableScore this_obj_conv;
42920         this_obj_conv.inner = (void*)(this_obj & (~1));
42921         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42923         MultiThreadedLockableScore_free(this_obj_conv);
42924 }
42925
42926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
42927         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
42928         CHECK_ACCESS(score_ptr);
42929         LDKScore score_conv = *(LDKScore*)(score_ptr);
42930         if (score_conv.free == LDKScore_JCalls_free) {
42931                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42932                 LDKScore_JCalls_cloned(&score_conv);
42933         }
42934         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
42935         int64_t ret_ref = 0;
42936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42939         ret_ref = (uintptr_t)ret_var.inner;
42940         if (ret_var.is_owned) {
42941                 ret_ref |= 1;
42942         }
42943         return ret_ref;
42944 }
42945
42946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42947         LDKFixedPenaltyScorer this_obj_conv;
42948         this_obj_conv.inner = (void*)(this_obj & (~1));
42949         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42951         FixedPenaltyScorer_free(this_obj_conv);
42952 }
42953
42954 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
42955         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
42956 int64_t ret_ref = 0;
42957 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42958 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42959 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42960 ret_ref = (uintptr_t)ret_var.inner;
42961 if (ret_var.is_owned) {
42962         ret_ref |= 1;
42963 }
42964         return ret_ref;
42965 }
42966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42967         LDKFixedPenaltyScorer arg_conv;
42968         arg_conv.inner = (void*)(arg & (~1));
42969         arg_conv.is_owned = false;
42970         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42971         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
42972         return ret_conv;
42973 }
42974
42975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42976         LDKFixedPenaltyScorer orig_conv;
42977         orig_conv.inner = (void*)(orig & (~1));
42978         orig_conv.is_owned = false;
42979         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42980         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
42981         int64_t ret_ref = 0;
42982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42985         ret_ref = (uintptr_t)ret_var.inner;
42986         if (ret_var.is_owned) {
42987                 ret_ref |= 1;
42988         }
42989         return ret_ref;
42990 }
42991
42992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
42993         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
42994         int64_t ret_ref = 0;
42995         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42996         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42998         ret_ref = (uintptr_t)ret_var.inner;
42999         if (ret_var.is_owned) {
43000                 ret_ref |= 1;
43001         }
43002         return ret_ref;
43003 }
43004
43005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
43006         LDKFixedPenaltyScorer this_arg_conv;
43007         this_arg_conv.inner = (void*)(this_arg & (~1));
43008         this_arg_conv.is_owned = false;
43009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43010         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43011         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
43012         return (int64_t)ret_ret;
43013 }
43014
43015 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
43016         LDKFixedPenaltyScorer obj_conv;
43017         obj_conv.inner = (void*)(obj & (~1));
43018         obj_conv.is_owned = false;
43019         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43020         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
43021         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43022         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43023         CVec_u8Z_free(ret_var);
43024         return ret_arr;
43025 }
43026
43027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
43028         LDKu8slice ser_ref;
43029         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43030         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43031         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
43032         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
43033         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43034         return (int64_t)ret_conv;
43035 }
43036
43037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43038         LDKScorer this_obj_conv;
43039         this_obj_conv.inner = (void*)(this_obj & (~1));
43040         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43042         Scorer_free(this_obj_conv);
43043 }
43044
43045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43046         LDKScoringParameters this_obj_conv;
43047         this_obj_conv.inner = (void*)(this_obj & (~1));
43048         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43050         ScoringParameters_free(this_obj_conv);
43051 }
43052
43053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43054         LDKScoringParameters this_ptr_conv;
43055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43056         this_ptr_conv.is_owned = false;
43057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43058         int64_t ret_conv = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
43059         return ret_conv;
43060 }
43061
43062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43063         LDKScoringParameters this_ptr_conv;
43064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43065         this_ptr_conv.is_owned = false;
43066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43067         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
43068 }
43069
43070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43071         LDKScoringParameters this_ptr_conv;
43072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43073         this_ptr_conv.is_owned = false;
43074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43075         int64_t ret_conv = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
43076         return ret_conv;
43077 }
43078
43079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43080         LDKScoringParameters this_ptr_conv;
43081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43082         this_ptr_conv.is_owned = false;
43083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43084         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
43085 }
43086
43087 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
43088         LDKScoringParameters this_ptr_conv;
43089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43090         this_ptr_conv.is_owned = false;
43091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43092         int16_t ret_conv = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
43093         return ret_conv;
43094 }
43095
43096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1overuse_1penalty_1start_11024th(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43097         LDKScoringParameters this_ptr_conv;
43098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43099         this_ptr_conv.is_owned = false;
43100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43101         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
43102 }
43103
43104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr) {
43105         LDKScoringParameters this_ptr_conv;
43106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43107         this_ptr_conv.is_owned = false;
43108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43109         int64_t ret_conv = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
43110         return ret_conv;
43111 }
43112
43113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1overuse_1penalty_1msat_1per_11024th(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43114         LDKScoringParameters this_ptr_conv;
43115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43116         this_ptr_conv.is_owned = false;
43117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43118         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
43119 }
43120
43121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
43122         LDKScoringParameters this_ptr_conv;
43123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43124         this_ptr_conv.is_owned = false;
43125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43126         int64_t ret_conv = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
43127         return ret_conv;
43128 }
43129
43130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43131         LDKScoringParameters this_ptr_conv;
43132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43133         this_ptr_conv.is_owned = false;
43134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43135         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
43136 }
43137
43138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int16_t overuse_penalty_start_1024th_arg, int64_t overuse_penalty_msat_per_1024th_arg, int64_t failure_penalty_half_life_arg) {
43139         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, overuse_penalty_start_1024th_arg, overuse_penalty_msat_per_1024th_arg, failure_penalty_half_life_arg);
43140         int64_t ret_ref = 0;
43141         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43142         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43144         ret_ref = (uintptr_t)ret_var.inner;
43145         if (ret_var.is_owned) {
43146                 ret_ref |= 1;
43147         }
43148         return ret_ref;
43149 }
43150
43151 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
43152         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
43153 int64_t ret_ref = 0;
43154 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43155 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43156 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43157 ret_ref = (uintptr_t)ret_var.inner;
43158 if (ret_var.is_owned) {
43159         ret_ref |= 1;
43160 }
43161         return ret_ref;
43162 }
43163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43164         LDKScoringParameters arg_conv;
43165         arg_conv.inner = (void*)(arg & (~1));
43166         arg_conv.is_owned = false;
43167         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43168         int64_t ret_conv = ScoringParameters_clone_ptr(&arg_conv);
43169         return ret_conv;
43170 }
43171
43172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43173         LDKScoringParameters orig_conv;
43174         orig_conv.inner = (void*)(orig & (~1));
43175         orig_conv.is_owned = false;
43176         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43177         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
43178         int64_t ret_ref = 0;
43179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43182         ret_ref = (uintptr_t)ret_var.inner;
43183         if (ret_var.is_owned) {
43184                 ret_ref |= 1;
43185         }
43186         return ret_ref;
43187 }
43188
43189 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
43190         LDKScoringParameters obj_conv;
43191         obj_conv.inner = (void*)(obj & (~1));
43192         obj_conv.is_owned = false;
43193         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43194         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
43195         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43196         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43197         CVec_u8Z_free(ret_var);
43198         return ret_arr;
43199 }
43200
43201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43202         LDKu8slice ser_ref;
43203         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43204         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43205         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
43206         *ret_conv = ScoringParameters_read(ser_ref);
43207         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43208         return (int64_t)ret_conv;
43209 }
43210
43211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
43212         LDKScoringParameters params_conv;
43213         params_conv.inner = (void*)(params & (~1));
43214         params_conv.is_owned = (params & 1) || (params == 0);
43215         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
43216         params_conv = ScoringParameters_clone(&params_conv);
43217         LDKScorer ret_var = Scorer_new(params_conv);
43218         int64_t ret_ref = 0;
43219         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43220         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43222         ret_ref = (uintptr_t)ret_var.inner;
43223         if (ret_var.is_owned) {
43224                 ret_ref |= 1;
43225         }
43226         return ret_ref;
43227 }
43228
43229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
43230         LDKScorer ret_var = Scorer_default();
43231         int64_t ret_ref = 0;
43232         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43233         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43235         ret_ref = (uintptr_t)ret_var.inner;
43236         if (ret_var.is_owned) {
43237                 ret_ref |= 1;
43238         }
43239         return ret_ref;
43240 }
43241
43242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1default(JNIEnv *env, jclass clz) {
43243         LDKScoringParameters ret_var = ScoringParameters_default();
43244         int64_t ret_ref = 0;
43245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43248         ret_ref = (uintptr_t)ret_var.inner;
43249         if (ret_var.is_owned) {
43250                 ret_ref |= 1;
43251         }
43252         return ret_ref;
43253 }
43254
43255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
43256         LDKScorer this_arg_conv;
43257         this_arg_conv.inner = (void*)(this_arg & (~1));
43258         this_arg_conv.is_owned = false;
43259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43260         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43261         *ret_ret = Scorer_as_Score(&this_arg_conv);
43262         return (int64_t)ret_ret;
43263 }
43264
43265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
43266         LDKScorer obj_conv;
43267         obj_conv.inner = (void*)(obj & (~1));
43268         obj_conv.is_owned = false;
43269         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43270         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
43271         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43272         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43273         CVec_u8Z_free(ret_var);
43274         return ret_arr;
43275 }
43276
43277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43278         LDKu8slice ser_ref;
43279         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43280         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43281         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
43282         *ret_conv = Scorer_read(ser_ref);
43283         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43284         return (int64_t)ret_conv;
43285 }
43286
43287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43288         LDKProbabilisticScorer this_obj_conv;
43289         this_obj_conv.inner = (void*)(this_obj & (~1));
43290         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43292         ProbabilisticScorer_free(this_obj_conv);
43293 }
43294
43295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43296         LDKProbabilisticScoringParameters this_obj_conv;
43297         this_obj_conv.inner = (void*)(this_obj & (~1));
43298         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43300         ProbabilisticScoringParameters_free(this_obj_conv);
43301 }
43302
43303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43304         LDKProbabilisticScoringParameters this_ptr_conv;
43305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43306         this_ptr_conv.is_owned = false;
43307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43308         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
43309         return ret_conv;
43310 }
43311
43312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43313         LDKProbabilisticScoringParameters this_ptr_conv;
43314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43315         this_ptr_conv.is_owned = false;
43316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43317         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
43318 }
43319
43320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43321         LDKProbabilisticScoringParameters this_ptr_conv;
43322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43323         this_ptr_conv.is_owned = false;
43324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43325         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
43326         return ret_conv;
43327 }
43328
43329 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) {
43330         LDKProbabilisticScoringParameters this_ptr_conv;
43331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43332         this_ptr_conv.is_owned = false;
43333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43334         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
43335 }
43336
43337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
43338         LDKProbabilisticScoringParameters this_ptr_conv;
43339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43340         this_ptr_conv.is_owned = false;
43341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43342         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
43343         return ret_conv;
43344 }
43345
43346 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) {
43347         LDKProbabilisticScoringParameters this_ptr_conv;
43348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43349         this_ptr_conv.is_owned = false;
43350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43351         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
43352 }
43353
43354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1amount_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43355         LDKProbabilisticScoringParameters this_ptr_conv;
43356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43357         this_ptr_conv.is_owned = false;
43358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43359         int64_t ret_conv = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
43360         return ret_conv;
43361 }
43362
43363 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) {
43364         LDKProbabilisticScoringParameters this_ptr_conv;
43365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
43366         this_ptr_conv.is_owned = false;
43367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43368         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
43369 }
43370
43371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t liquidity_penalty_multiplier_msat_arg, int64_t liquidity_offset_half_life_arg, int64_t amount_penalty_multiplier_msat_arg) {
43372         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(base_penalty_msat_arg, liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg, amount_penalty_multiplier_msat_arg);
43373         int64_t ret_ref = 0;
43374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43377         ret_ref = (uintptr_t)ret_var.inner;
43378         if (ret_var.is_owned) {
43379                 ret_ref |= 1;
43380         }
43381         return ret_ref;
43382 }
43383
43384 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
43385         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
43386 int64_t ret_ref = 0;
43387 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43388 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43389 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43390 ret_ref = (uintptr_t)ret_var.inner;
43391 if (ret_var.is_owned) {
43392         ret_ref |= 1;
43393 }
43394         return ret_ref;
43395 }
43396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43397         LDKProbabilisticScoringParameters arg_conv;
43398         arg_conv.inner = (void*)(arg & (~1));
43399         arg_conv.is_owned = false;
43400         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43401         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
43402         return ret_conv;
43403 }
43404
43405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43406         LDKProbabilisticScoringParameters orig_conv;
43407         orig_conv.inner = (void*)(orig & (~1));
43408         orig_conv.is_owned = false;
43409         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43410         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
43411         int64_t ret_ref = 0;
43412         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43413         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43415         ret_ref = (uintptr_t)ret_var.inner;
43416         if (ret_var.is_owned) {
43417                 ret_ref |= 1;
43418         }
43419         return ret_ref;
43420 }
43421
43422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1new(JNIEnv *env, jclass clz, int64_t params, int64_t network_graph) {
43423         LDKProbabilisticScoringParameters params_conv;
43424         params_conv.inner = (void*)(params & (~1));
43425         params_conv.is_owned = (params & 1) || (params == 0);
43426         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
43427         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
43428         LDKNetworkGraph network_graph_conv;
43429         network_graph_conv.inner = (void*)(network_graph & (~1));
43430         network_graph_conv.is_owned = false;
43431         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43432         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv);
43433         int64_t ret_ref = 0;
43434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43437         ret_ref = (uintptr_t)ret_var.inner;
43438         if (ret_var.is_owned) {
43439                 ret_ref |= 1;
43440         }
43441         return ret_ref;
43442 }
43443
43444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
43445         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
43446         int64_t ret_ref = 0;
43447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43450         ret_ref = (uintptr_t)ret_var.inner;
43451         if (ret_var.is_owned) {
43452                 ret_ref |= 1;
43453         }
43454         return ret_ref;
43455 }
43456
43457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
43458         LDKProbabilisticScorer this_arg_conv;
43459         this_arg_conv.inner = (void*)(this_arg & (~1));
43460         this_arg_conv.is_owned = false;
43461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43462         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
43463         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
43464         return (int64_t)ret_ret;
43465 }
43466
43467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
43468         LDKProbabilisticScorer obj_conv;
43469         obj_conv.inner = (void*)(obj & (~1));
43470         obj_conv.is_owned = false;
43471         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43472         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
43473         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43474         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43475         CVec_u8Z_free(ret_var);
43476         return ret_arr;
43477 }
43478
43479 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) {
43480         LDKu8slice ser_ref;
43481         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43482         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43483         LDKProbabilisticScoringParameters arg_a_conv;
43484         arg_a_conv.inner = (void*)(arg_a & (~1));
43485         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
43486         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
43487         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
43488         LDKNetworkGraph arg_b_conv;
43489         arg_b_conv.inner = (void*)(arg_b & (~1));
43490         arg_b_conv.is_owned = false;
43491         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
43492         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
43493         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv);
43494         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43495         return (int64_t)ret_conv;
43496 }
43497
43498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43499         LDKFilesystemPersister this_obj_conv;
43500         this_obj_conv.inner = (void*)(this_obj & (~1));
43501         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43503         FilesystemPersister_free(this_obj_conv);
43504 }
43505
43506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
43507         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
43508         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
43509         int64_t ret_ref = 0;
43510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43513         ret_ref = (uintptr_t)ret_var.inner;
43514         if (ret_var.is_owned) {
43515                 ret_ref |= 1;
43516         }
43517         return ret_ref;
43518 }
43519
43520 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
43521         LDKFilesystemPersister this_arg_conv;
43522         this_arg_conv.inner = (void*)(this_arg & (~1));
43523         this_arg_conv.is_owned = false;
43524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43525         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
43526         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
43527         Str_free(ret_str);
43528         return ret_conv;
43529 }
43530
43531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
43532         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
43533         LDKChannelManager manager_conv;
43534         manager_conv.inner = (void*)(manager & (~1));
43535         manager_conv.is_owned = false;
43536         CHECK_INNER_FIELD_ACCESS_OR_NULL(manager_conv);
43537         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43538         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
43539         return (int64_t)ret_conv;
43540 }
43541
43542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1network_1graph(JNIEnv *env, jclass clz, jstring data_dir, int64_t network_graph) {
43543         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
43544         LDKNetworkGraph network_graph_conv;
43545         network_graph_conv.inner = (void*)(network_graph & (~1));
43546         network_graph_conv.is_owned = false;
43547         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43548         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43549         *ret_conv = FilesystemPersister_persist_network_graph(data_dir_conv, &network_graph_conv);
43550         return (int64_t)ret_conv;
43551 }
43552
43553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
43554         LDKFilesystemPersister this_arg_conv;
43555         this_arg_conv.inner = (void*)(this_arg & (~1));
43556         this_arg_conv.is_owned = false;
43557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43558         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
43559         CHECK_ACCESS(keys_manager_ptr);
43560         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
43561         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
43562                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43563                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
43564         }
43565         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
43566         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
43567         return (int64_t)ret_conv;
43568 }
43569
43570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
43571         LDKFilesystemPersister this_arg_conv;
43572         this_arg_conv.inner = (void*)(this_arg & (~1));
43573         this_arg_conv.is_owned = false;
43574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43575         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
43576         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
43577         return (int64_t)ret_ret;
43578 }
43579
43580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43581         LDKBackgroundProcessor this_obj_conv;
43582         this_obj_conv.inner = (void*)(this_obj & (~1));
43583         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43585         BackgroundProcessor_free(this_obj_conv);
43586 }
43587
43588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43589         if ((this_ptr & 1) != 0) return;
43590         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43591         CHECK_ACCESS(this_ptr_ptr);
43592         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
43593         FREE((void*)this_ptr);
43594         Persister_free(this_ptr_conv);
43595 }
43596
43597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t net_graph_msg_handler, int64_t peer_manager, int64_t logger) {
43598         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
43599         CHECK_ACCESS(persister_ptr);
43600         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
43601         if (persister_conv.free == LDKPersister_JCalls_free) {
43602                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43603                 LDKPersister_JCalls_cloned(&persister_conv);
43604         }
43605         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
43606         CHECK_ACCESS(event_handler_ptr);
43607         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
43608         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
43609                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43610                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
43611         }
43612         LDKChainMonitor chain_monitor_conv;
43613         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
43614         chain_monitor_conv.is_owned = false;
43615         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
43616         LDKChannelManager channel_manager_conv;
43617         channel_manager_conv.inner = (void*)(channel_manager & (~1));
43618         channel_manager_conv.is_owned = false;
43619         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
43620         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
43621         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
43622         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
43623         CHECK_INNER_FIELD_ACCESS_OR_NULL(net_graph_msg_handler_conv);
43624         LDKPeerManager peer_manager_conv;
43625         peer_manager_conv.inner = (void*)(peer_manager & (~1));
43626         peer_manager_conv.is_owned = false;
43627         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
43628         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43629         CHECK_ACCESS(logger_ptr);
43630         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43631         if (logger_conv.free == LDKLogger_JCalls_free) {
43632                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43633                 LDKLogger_JCalls_cloned(&logger_conv);
43634         }
43635         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv);
43636         int64_t ret_ref = 0;
43637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43640         ret_ref = (uintptr_t)ret_var.inner;
43641         if (ret_var.is_owned) {
43642                 ret_ref |= 1;
43643         }
43644         return ret_ref;
43645 }
43646
43647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
43648         LDKBackgroundProcessor this_arg_conv;
43649         this_arg_conv.inner = (void*)(this_arg & (~1));
43650         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43652         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
43653         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43654         *ret_conv = BackgroundProcessor_join(this_arg_conv);
43655         return (int64_t)ret_conv;
43656 }
43657
43658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
43659         LDKBackgroundProcessor this_arg_conv;
43660         this_arg_conv.inner = (void*)(this_arg & (~1));
43661         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43663         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
43664         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
43665         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
43666         return (int64_t)ret_conv;
43667 }
43668
43669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43670         if ((this_ptr & 1) != 0) return;
43671         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43672         CHECK_ACCESS(this_ptr_ptr);
43673         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
43674         FREE((void*)this_ptr);
43675         ParseError_free(this_ptr_conv);
43676 }
43677
43678 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
43679         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43680         *ret_copy = ParseError_clone(arg);
43681 int64_t ret_ref = (uintptr_t)ret_copy;
43682         return ret_ref;
43683 }
43684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43685         LDKParseError* arg_conv = (LDKParseError*)arg;
43686         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
43687         return ret_conv;
43688 }
43689
43690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43691         LDKParseError* orig_conv = (LDKParseError*)orig;
43692         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43693         *ret_copy = ParseError_clone(orig_conv);
43694         int64_t ret_ref = (uintptr_t)ret_copy;
43695         return ret_ref;
43696 }
43697
43698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
43699         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43700         CHECK_ACCESS(a_ptr);
43701         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
43702         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
43703         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43704         *ret_copy = ParseError_bech32_error(a_conv);
43705         int64_t ret_ref = (uintptr_t)ret_copy;
43706         return ret_ref;
43707 }
43708
43709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
43710         
43711         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43712         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
43713         int64_t ret_ref = (uintptr_t)ret_copy;
43714         return ret_ref;
43715 }
43716
43717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
43718         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
43719         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43720         *ret_copy = ParseError_malformed_signature(a_conv);
43721         int64_t ret_ref = (uintptr_t)ret_copy;
43722         return ret_ref;
43723 }
43724
43725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
43726         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43727         *ret_copy = ParseError_bad_prefix();
43728         int64_t ret_ref = (uintptr_t)ret_copy;
43729         return ret_ref;
43730 }
43731
43732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
43733         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43734         *ret_copy = ParseError_unknown_currency();
43735         int64_t ret_ref = (uintptr_t)ret_copy;
43736         return ret_ref;
43737 }
43738
43739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
43740         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43741         *ret_copy = ParseError_unknown_si_prefix();
43742         int64_t ret_ref = (uintptr_t)ret_copy;
43743         return ret_ref;
43744 }
43745
43746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
43747         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43748         *ret_copy = ParseError_malformed_hrp();
43749         int64_t ret_ref = (uintptr_t)ret_copy;
43750         return ret_ref;
43751 }
43752
43753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
43754         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43755         *ret_copy = ParseError_too_short_data_part();
43756         int64_t ret_ref = (uintptr_t)ret_copy;
43757         return ret_ref;
43758 }
43759
43760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
43761         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43762         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
43763         int64_t ret_ref = (uintptr_t)ret_copy;
43764         return ret_ref;
43765 }
43766
43767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
43768         
43769         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43770         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
43771         int64_t ret_ref = (uintptr_t)ret_copy;
43772         return ret_ref;
43773 }
43774
43775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
43776         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43777         *ret_copy = ParseError_padding_error();
43778         int64_t ret_ref = (uintptr_t)ret_copy;
43779         return ret_ref;
43780 }
43781
43782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
43783         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43784         *ret_copy = ParseError_integer_overflow_error();
43785         int64_t ret_ref = (uintptr_t)ret_copy;
43786         return ret_ref;
43787 }
43788
43789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
43790         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43791         *ret_copy = ParseError_invalid_seg_wit_program_length();
43792         int64_t ret_ref = (uintptr_t)ret_copy;
43793         return ret_ref;
43794 }
43795
43796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
43797         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43798         *ret_copy = ParseError_invalid_pub_key_hash_length();
43799         int64_t ret_ref = (uintptr_t)ret_copy;
43800         return ret_ref;
43801 }
43802
43803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
43804         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43805         *ret_copy = ParseError_invalid_script_hash_length();
43806         int64_t ret_ref = (uintptr_t)ret_copy;
43807         return ret_ref;
43808 }
43809
43810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
43811         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43812         *ret_copy = ParseError_invalid_recovery_id();
43813         int64_t ret_ref = (uintptr_t)ret_copy;
43814         return ret_ref;
43815 }
43816
43817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
43818         LDKStr a_conv = java_to_owned_str(env, a);
43819         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43820         *ret_copy = ParseError_invalid_slice_length(a_conv);
43821         int64_t ret_ref = (uintptr_t)ret_copy;
43822         return ret_ref;
43823 }
43824
43825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
43826         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
43827         *ret_copy = ParseError_skip();
43828         int64_t ret_ref = (uintptr_t)ret_copy;
43829         return ret_ref;
43830 }
43831
43832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43833         if ((this_ptr & 1) != 0) return;
43834         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43835         CHECK_ACCESS(this_ptr_ptr);
43836         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
43837         FREE((void*)this_ptr);
43838         ParseOrSemanticError_free(this_ptr_conv);
43839 }
43840
43841 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
43842         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43843         *ret_copy = ParseOrSemanticError_clone(arg);
43844 int64_t ret_ref = (uintptr_t)ret_copy;
43845         return ret_ref;
43846 }
43847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43848         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
43849         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
43850         return ret_conv;
43851 }
43852
43853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43854         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
43855         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43856         *ret_copy = ParseOrSemanticError_clone(orig_conv);
43857         int64_t ret_ref = (uintptr_t)ret_copy;
43858         return ret_ref;
43859 }
43860
43861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
43862         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43863         CHECK_ACCESS(a_ptr);
43864         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
43865         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
43866         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43867         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
43868         int64_t ret_ref = (uintptr_t)ret_copy;
43869         return ret_ref;
43870 }
43871
43872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
43873         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
43874         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
43875         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
43876         int64_t ret_ref = (uintptr_t)ret_copy;
43877         return ret_ref;
43878 }
43879
43880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43881         LDKInvoice this_obj_conv;
43882         this_obj_conv.inner = (void*)(this_obj & (~1));
43883         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43885         Invoice_free(this_obj_conv);
43886 }
43887
43888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43889         LDKInvoice a_conv;
43890         a_conv.inner = (void*)(a & (~1));
43891         a_conv.is_owned = false;
43892         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43893         LDKInvoice b_conv;
43894         b_conv.inner = (void*)(b & (~1));
43895         b_conv.is_owned = false;
43896         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43897         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
43898         return ret_conv;
43899 }
43900
43901 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
43902         LDKInvoice ret_var = Invoice_clone(arg);
43903 int64_t ret_ref = 0;
43904 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43905 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43906 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43907 ret_ref = (uintptr_t)ret_var.inner;
43908 if (ret_var.is_owned) {
43909         ret_ref |= 1;
43910 }
43911         return ret_ref;
43912 }
43913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43914         LDKInvoice arg_conv;
43915         arg_conv.inner = (void*)(arg & (~1));
43916         arg_conv.is_owned = false;
43917         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43918         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
43919         return ret_conv;
43920 }
43921
43922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43923         LDKInvoice orig_conv;
43924         orig_conv.inner = (void*)(orig & (~1));
43925         orig_conv.is_owned = false;
43926         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43927         LDKInvoice ret_var = Invoice_clone(&orig_conv);
43928         int64_t ret_ref = 0;
43929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43932         ret_ref = (uintptr_t)ret_var.inner;
43933         if (ret_var.is_owned) {
43934                 ret_ref |= 1;
43935         }
43936         return ret_ref;
43937 }
43938
43939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43940         LDKSignedRawInvoice 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         SignedRawInvoice_free(this_obj_conv);
43945 }
43946
43947 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43948         LDKSignedRawInvoice a_conv;
43949         a_conv.inner = (void*)(a & (~1));
43950         a_conv.is_owned = false;
43951         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43952         LDKSignedRawInvoice b_conv;
43953         b_conv.inner = (void*)(b & (~1));
43954         b_conv.is_owned = false;
43955         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43956         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
43957         return ret_conv;
43958 }
43959
43960 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
43961         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
43962 int64_t ret_ref = 0;
43963 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43964 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43965 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43966 ret_ref = (uintptr_t)ret_var.inner;
43967 if (ret_var.is_owned) {
43968         ret_ref |= 1;
43969 }
43970         return ret_ref;
43971 }
43972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43973         LDKSignedRawInvoice arg_conv;
43974         arg_conv.inner = (void*)(arg & (~1));
43975         arg_conv.is_owned = false;
43976         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43977         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
43978         return ret_conv;
43979 }
43980
43981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43982         LDKSignedRawInvoice orig_conv;
43983         orig_conv.inner = (void*)(orig & (~1));
43984         orig_conv.is_owned = false;
43985         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43986         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
43987         int64_t ret_ref = 0;
43988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43991         ret_ref = (uintptr_t)ret_var.inner;
43992         if (ret_var.is_owned) {
43993                 ret_ref |= 1;
43994         }
43995         return ret_ref;
43996 }
43997
43998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43999         LDKRawInvoice this_obj_conv;
44000         this_obj_conv.inner = (void*)(this_obj & (~1));
44001         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44003         RawInvoice_free(this_obj_conv);
44004 }
44005
44006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
44007         LDKRawInvoice this_ptr_conv;
44008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44009         this_ptr_conv.is_owned = false;
44010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44011         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
44012         int64_t ret_ref = 0;
44013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44016         ret_ref = (uintptr_t)ret_var.inner;
44017         if (ret_var.is_owned) {
44018                 ret_ref |= 1;
44019         }
44020         return ret_ref;
44021 }
44022
44023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44024         LDKRawInvoice this_ptr_conv;
44025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44026         this_ptr_conv.is_owned = false;
44027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44028         LDKRawDataPart val_conv;
44029         val_conv.inner = (void*)(val & (~1));
44030         val_conv.is_owned = (val & 1) || (val == 0);
44031         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44032         val_conv = RawDataPart_clone(&val_conv);
44033         RawInvoice_set_data(&this_ptr_conv, val_conv);
44034 }
44035
44036 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44037         LDKRawInvoice a_conv;
44038         a_conv.inner = (void*)(a & (~1));
44039         a_conv.is_owned = false;
44040         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44041         LDKRawInvoice b_conv;
44042         b_conv.inner = (void*)(b & (~1));
44043         b_conv.is_owned = false;
44044         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44045         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
44046         return ret_conv;
44047 }
44048
44049 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
44050         LDKRawInvoice ret_var = RawInvoice_clone(arg);
44051 int64_t ret_ref = 0;
44052 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44053 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44054 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44055 ret_ref = (uintptr_t)ret_var.inner;
44056 if (ret_var.is_owned) {
44057         ret_ref |= 1;
44058 }
44059         return ret_ref;
44060 }
44061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44062         LDKRawInvoice arg_conv;
44063         arg_conv.inner = (void*)(arg & (~1));
44064         arg_conv.is_owned = false;
44065         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44066         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
44067         return ret_conv;
44068 }
44069
44070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44071         LDKRawInvoice orig_conv;
44072         orig_conv.inner = (void*)(orig & (~1));
44073         orig_conv.is_owned = false;
44074         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44075         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
44076         int64_t ret_ref = 0;
44077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44080         ret_ref = (uintptr_t)ret_var.inner;
44081         if (ret_var.is_owned) {
44082                 ret_ref |= 1;
44083         }
44084         return ret_ref;
44085 }
44086
44087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44088         LDKRawDataPart this_obj_conv;
44089         this_obj_conv.inner = (void*)(this_obj & (~1));
44090         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44092         RawDataPart_free(this_obj_conv);
44093 }
44094
44095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
44096         LDKRawDataPart this_ptr_conv;
44097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44098         this_ptr_conv.is_owned = false;
44099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44100         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
44101         int64_t ret_ref = 0;
44102         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44103         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44105         ret_ref = (uintptr_t)ret_var.inner;
44106         if (ret_var.is_owned) {
44107                 ret_ref |= 1;
44108         }
44109         return ret_ref;
44110 }
44111
44112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44113         LDKRawDataPart this_ptr_conv;
44114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44115         this_ptr_conv.is_owned = false;
44116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44117         LDKPositiveTimestamp val_conv;
44118         val_conv.inner = (void*)(val & (~1));
44119         val_conv.is_owned = (val & 1) || (val == 0);
44120         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44121         val_conv = PositiveTimestamp_clone(&val_conv);
44122         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
44123 }
44124
44125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44126         LDKRawDataPart a_conv;
44127         a_conv.inner = (void*)(a & (~1));
44128         a_conv.is_owned = false;
44129         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44130         LDKRawDataPart b_conv;
44131         b_conv.inner = (void*)(b & (~1));
44132         b_conv.is_owned = false;
44133         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44134         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
44135         return ret_conv;
44136 }
44137
44138 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
44139         LDKRawDataPart ret_var = RawDataPart_clone(arg);
44140 int64_t ret_ref = 0;
44141 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44142 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44143 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44144 ret_ref = (uintptr_t)ret_var.inner;
44145 if (ret_var.is_owned) {
44146         ret_ref |= 1;
44147 }
44148         return ret_ref;
44149 }
44150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44151         LDKRawDataPart arg_conv;
44152         arg_conv.inner = (void*)(arg & (~1));
44153         arg_conv.is_owned = false;
44154         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44155         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
44156         return ret_conv;
44157 }
44158
44159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44160         LDKRawDataPart orig_conv;
44161         orig_conv.inner = (void*)(orig & (~1));
44162         orig_conv.is_owned = false;
44163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44164         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
44165         int64_t ret_ref = 0;
44166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44169         ret_ref = (uintptr_t)ret_var.inner;
44170         if (ret_var.is_owned) {
44171                 ret_ref |= 1;
44172         }
44173         return ret_ref;
44174 }
44175
44176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44177         LDKPositiveTimestamp this_obj_conv;
44178         this_obj_conv.inner = (void*)(this_obj & (~1));
44179         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44181         PositiveTimestamp_free(this_obj_conv);
44182 }
44183
44184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44185         LDKPositiveTimestamp a_conv;
44186         a_conv.inner = (void*)(a & (~1));
44187         a_conv.is_owned = false;
44188         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44189         LDKPositiveTimestamp b_conv;
44190         b_conv.inner = (void*)(b & (~1));
44191         b_conv.is_owned = false;
44192         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44193         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
44194         return ret_conv;
44195 }
44196
44197 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
44198         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
44199 int64_t ret_ref = 0;
44200 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44201 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44202 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44203 ret_ref = (uintptr_t)ret_var.inner;
44204 if (ret_var.is_owned) {
44205         ret_ref |= 1;
44206 }
44207         return ret_ref;
44208 }
44209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44210         LDKPositiveTimestamp arg_conv;
44211         arg_conv.inner = (void*)(arg & (~1));
44212         arg_conv.is_owned = false;
44213         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44214         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
44215         return ret_conv;
44216 }
44217
44218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44219         LDKPositiveTimestamp orig_conv;
44220         orig_conv.inner = (void*)(orig & (~1));
44221         orig_conv.is_owned = false;
44222         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44223         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
44224         int64_t ret_ref = 0;
44225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44228         ret_ref = (uintptr_t)ret_var.inner;
44229         if (ret_var.is_owned) {
44230                 ret_ref |= 1;
44231         }
44232         return ret_ref;
44233 }
44234
44235 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44236         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
44237         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
44238         return ret_conv;
44239 }
44240
44241 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
44242         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
44243         return ret_conv;
44244 }
44245
44246 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
44247         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
44248         return ret_conv;
44249 }
44250
44251 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
44252         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
44253         return ret_conv;
44254 }
44255
44256 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
44257         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
44258         return ret_conv;
44259 }
44260
44261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44262         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
44263         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
44264         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
44265         return ret_conv;
44266 }
44267
44268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
44269         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
44270         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
44271         return ret_conv;
44272 }
44273
44274 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44275         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
44276         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
44277         return ret_conv;
44278 }
44279
44280 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
44281         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
44282         return ret_conv;
44283 }
44284
44285 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
44286         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
44287         return ret_conv;
44288 }
44289
44290 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
44291         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
44292         return ret_conv;
44293 }
44294
44295 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
44296         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
44297         return ret_conv;
44298 }
44299
44300 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
44301         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
44302         return ret_conv;
44303 }
44304
44305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
44306         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
44307         int64_t ret_conv = Currency_hash(o_conv);
44308         return ret_conv;
44309 }
44310
44311 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44312         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
44313         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
44314         jboolean ret_conv = Currency_eq(a_conv, b_conv);
44315         return ret_conv;
44316 }
44317
44318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44319         LDKSha256 this_obj_conv;
44320         this_obj_conv.inner = (void*)(this_obj & (~1));
44321         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44323         Sha256_free(this_obj_conv);
44324 }
44325
44326 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
44327         LDKSha256 ret_var = Sha256_clone(arg);
44328 int64_t ret_ref = 0;
44329 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44330 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44331 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44332 ret_ref = (uintptr_t)ret_var.inner;
44333 if (ret_var.is_owned) {
44334         ret_ref |= 1;
44335 }
44336         return ret_ref;
44337 }
44338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44339         LDKSha256 arg_conv;
44340         arg_conv.inner = (void*)(arg & (~1));
44341         arg_conv.is_owned = false;
44342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44343         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
44344         return ret_conv;
44345 }
44346
44347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44348         LDKSha256 orig_conv;
44349         orig_conv.inner = (void*)(orig & (~1));
44350         orig_conv.is_owned = false;
44351         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44352         LDKSha256 ret_var = Sha256_clone(&orig_conv);
44353         int64_t ret_ref = 0;
44354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44357         ret_ref = (uintptr_t)ret_var.inner;
44358         if (ret_var.is_owned) {
44359                 ret_ref |= 1;
44360         }
44361         return ret_ref;
44362 }
44363
44364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
44365         LDKSha256 o_conv;
44366         o_conv.inner = (void*)(o & (~1));
44367         o_conv.is_owned = false;
44368         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44369         int64_t ret_conv = Sha256_hash(&o_conv);
44370         return ret_conv;
44371 }
44372
44373 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44374         LDKSha256 a_conv;
44375         a_conv.inner = (void*)(a & (~1));
44376         a_conv.is_owned = false;
44377         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44378         LDKSha256 b_conv;
44379         b_conv.inner = (void*)(b & (~1));
44380         b_conv.is_owned = false;
44381         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44382         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
44383         return ret_conv;
44384 }
44385
44386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44387         LDKDescription this_obj_conv;
44388         this_obj_conv.inner = (void*)(this_obj & (~1));
44389         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44391         Description_free(this_obj_conv);
44392 }
44393
44394 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
44395         LDKDescription ret_var = Description_clone(arg);
44396 int64_t ret_ref = 0;
44397 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44398 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44399 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44400 ret_ref = (uintptr_t)ret_var.inner;
44401 if (ret_var.is_owned) {
44402         ret_ref |= 1;
44403 }
44404         return ret_ref;
44405 }
44406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44407         LDKDescription arg_conv;
44408         arg_conv.inner = (void*)(arg & (~1));
44409         arg_conv.is_owned = false;
44410         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44411         int64_t ret_conv = Description_clone_ptr(&arg_conv);
44412         return ret_conv;
44413 }
44414
44415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44416         LDKDescription orig_conv;
44417         orig_conv.inner = (void*)(orig & (~1));
44418         orig_conv.is_owned = false;
44419         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44420         LDKDescription ret_var = Description_clone(&orig_conv);
44421         int64_t ret_ref = 0;
44422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44425         ret_ref = (uintptr_t)ret_var.inner;
44426         if (ret_var.is_owned) {
44427                 ret_ref |= 1;
44428         }
44429         return ret_ref;
44430 }
44431
44432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
44433         LDKDescription o_conv;
44434         o_conv.inner = (void*)(o & (~1));
44435         o_conv.is_owned = false;
44436         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44437         int64_t ret_conv = Description_hash(&o_conv);
44438         return ret_conv;
44439 }
44440
44441 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44442         LDKDescription a_conv;
44443         a_conv.inner = (void*)(a & (~1));
44444         a_conv.is_owned = false;
44445         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44446         LDKDescription b_conv;
44447         b_conv.inner = (void*)(b & (~1));
44448         b_conv.is_owned = false;
44449         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44450         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
44451         return ret_conv;
44452 }
44453
44454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44455         LDKPayeePubKey this_obj_conv;
44456         this_obj_conv.inner = (void*)(this_obj & (~1));
44457         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44459         PayeePubKey_free(this_obj_conv);
44460 }
44461
44462 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44463         LDKPayeePubKey this_ptr_conv;
44464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44465         this_ptr_conv.is_owned = false;
44466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44467         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
44468         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
44469         return ret_arr;
44470 }
44471
44472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44473         LDKPayeePubKey this_ptr_conv;
44474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44475         this_ptr_conv.is_owned = false;
44476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44477         LDKPublicKey val_ref;
44478         CHECK((*env)->GetArrayLength(env, val) == 33);
44479         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
44480         PayeePubKey_set_a(&this_ptr_conv, val_ref);
44481 }
44482
44483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
44484         LDKPublicKey a_arg_ref;
44485         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
44486         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
44487         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
44488         int64_t ret_ref = 0;
44489         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44490         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44492         ret_ref = (uintptr_t)ret_var.inner;
44493         if (ret_var.is_owned) {
44494                 ret_ref |= 1;
44495         }
44496         return ret_ref;
44497 }
44498
44499 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
44500         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
44501 int64_t ret_ref = 0;
44502 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44503 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44504 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44505 ret_ref = (uintptr_t)ret_var.inner;
44506 if (ret_var.is_owned) {
44507         ret_ref |= 1;
44508 }
44509         return ret_ref;
44510 }
44511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44512         LDKPayeePubKey arg_conv;
44513         arg_conv.inner = (void*)(arg & (~1));
44514         arg_conv.is_owned = false;
44515         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44516         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
44517         return ret_conv;
44518 }
44519
44520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44521         LDKPayeePubKey orig_conv;
44522         orig_conv.inner = (void*)(orig & (~1));
44523         orig_conv.is_owned = false;
44524         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44525         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
44526         int64_t ret_ref = 0;
44527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44530         ret_ref = (uintptr_t)ret_var.inner;
44531         if (ret_var.is_owned) {
44532                 ret_ref |= 1;
44533         }
44534         return ret_ref;
44535 }
44536
44537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
44538         LDKPayeePubKey o_conv;
44539         o_conv.inner = (void*)(o & (~1));
44540         o_conv.is_owned = false;
44541         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44542         int64_t ret_conv = PayeePubKey_hash(&o_conv);
44543         return ret_conv;
44544 }
44545
44546 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44547         LDKPayeePubKey a_conv;
44548         a_conv.inner = (void*)(a & (~1));
44549         a_conv.is_owned = false;
44550         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44551         LDKPayeePubKey b_conv;
44552         b_conv.inner = (void*)(b & (~1));
44553         b_conv.is_owned = false;
44554         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44555         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
44556         return ret_conv;
44557 }
44558
44559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44560         LDKExpiryTime this_obj_conv;
44561         this_obj_conv.inner = (void*)(this_obj & (~1));
44562         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44564         ExpiryTime_free(this_obj_conv);
44565 }
44566
44567 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
44568         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
44569 int64_t ret_ref = 0;
44570 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44571 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44572 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44573 ret_ref = (uintptr_t)ret_var.inner;
44574 if (ret_var.is_owned) {
44575         ret_ref |= 1;
44576 }
44577         return ret_ref;
44578 }
44579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44580         LDKExpiryTime arg_conv;
44581         arg_conv.inner = (void*)(arg & (~1));
44582         arg_conv.is_owned = false;
44583         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44584         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
44585         return ret_conv;
44586 }
44587
44588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44589         LDKExpiryTime orig_conv;
44590         orig_conv.inner = (void*)(orig & (~1));
44591         orig_conv.is_owned = false;
44592         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44593         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
44594         int64_t ret_ref = 0;
44595         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44596         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44598         ret_ref = (uintptr_t)ret_var.inner;
44599         if (ret_var.is_owned) {
44600                 ret_ref |= 1;
44601         }
44602         return ret_ref;
44603 }
44604
44605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
44606         LDKExpiryTime o_conv;
44607         o_conv.inner = (void*)(o & (~1));
44608         o_conv.is_owned = false;
44609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44610         int64_t ret_conv = ExpiryTime_hash(&o_conv);
44611         return ret_conv;
44612 }
44613
44614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44615         LDKExpiryTime a_conv;
44616         a_conv.inner = (void*)(a & (~1));
44617         a_conv.is_owned = false;
44618         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44619         LDKExpiryTime b_conv;
44620         b_conv.inner = (void*)(b & (~1));
44621         b_conv.is_owned = false;
44622         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44623         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
44624         return ret_conv;
44625 }
44626
44627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44628         LDKMinFinalCltvExpiry this_obj_conv;
44629         this_obj_conv.inner = (void*)(this_obj & (~1));
44630         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44632         MinFinalCltvExpiry_free(this_obj_conv);
44633 }
44634
44635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44636         LDKMinFinalCltvExpiry this_ptr_conv;
44637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44638         this_ptr_conv.is_owned = false;
44639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44640         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
44641         return ret_conv;
44642 }
44643
44644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44645         LDKMinFinalCltvExpiry this_ptr_conv;
44646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
44647         this_ptr_conv.is_owned = false;
44648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44649         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
44650 }
44651
44652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
44653         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
44654         int64_t ret_ref = 0;
44655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44658         ret_ref = (uintptr_t)ret_var.inner;
44659         if (ret_var.is_owned) {
44660                 ret_ref |= 1;
44661         }
44662         return ret_ref;
44663 }
44664
44665 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
44666         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
44667 int64_t ret_ref = 0;
44668 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44669 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44670 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44671 ret_ref = (uintptr_t)ret_var.inner;
44672 if (ret_var.is_owned) {
44673         ret_ref |= 1;
44674 }
44675         return ret_ref;
44676 }
44677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44678         LDKMinFinalCltvExpiry arg_conv;
44679         arg_conv.inner = (void*)(arg & (~1));
44680         arg_conv.is_owned = false;
44681         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44682         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
44683         return ret_conv;
44684 }
44685
44686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44687         LDKMinFinalCltvExpiry orig_conv;
44688         orig_conv.inner = (void*)(orig & (~1));
44689         orig_conv.is_owned = false;
44690         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44691         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
44692         int64_t ret_ref = 0;
44693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44696         ret_ref = (uintptr_t)ret_var.inner;
44697         if (ret_var.is_owned) {
44698                 ret_ref |= 1;
44699         }
44700         return ret_ref;
44701 }
44702
44703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
44704         LDKMinFinalCltvExpiry o_conv;
44705         o_conv.inner = (void*)(o & (~1));
44706         o_conv.is_owned = false;
44707         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44708         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
44709         return ret_conv;
44710 }
44711
44712 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44713         LDKMinFinalCltvExpiry a_conv;
44714         a_conv.inner = (void*)(a & (~1));
44715         a_conv.is_owned = false;
44716         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44717         LDKMinFinalCltvExpiry b_conv;
44718         b_conv.inner = (void*)(b & (~1));
44719         b_conv.is_owned = false;
44720         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44721         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
44722         return ret_conv;
44723 }
44724
44725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44726         if ((this_ptr & 1) != 0) return;
44727         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
44728         CHECK_ACCESS(this_ptr_ptr);
44729         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
44730         FREE((void*)this_ptr);
44731         Fallback_free(this_ptr_conv);
44732 }
44733
44734 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
44735         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44736         *ret_copy = Fallback_clone(arg);
44737 int64_t ret_ref = (uintptr_t)ret_copy;
44738         return ret_ref;
44739 }
44740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44741         LDKFallback* arg_conv = (LDKFallback*)arg;
44742         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
44743         return ret_conv;
44744 }
44745
44746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44747         LDKFallback* orig_conv = (LDKFallback*)orig;
44748         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44749         *ret_copy = Fallback_clone(orig_conv);
44750         int64_t ret_ref = (uintptr_t)ret_copy;
44751         return ret_ref;
44752 }
44753
44754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
44755         
44756         LDKCVec_u8Z program_ref;
44757         program_ref.datalen = (*env)->GetArrayLength(env, program);
44758         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
44759         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
44760         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44761         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
44762         int64_t ret_ref = (uintptr_t)ret_copy;
44763         return ret_ref;
44764 }
44765
44766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
44767         LDKTwentyBytes a_ref;
44768         CHECK((*env)->GetArrayLength(env, a) == 20);
44769         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
44770         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44771         *ret_copy = Fallback_pub_key_hash(a_ref);
44772         int64_t ret_ref = (uintptr_t)ret_copy;
44773         return ret_ref;
44774 }
44775
44776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
44777         LDKTwentyBytes a_ref;
44778         CHECK((*env)->GetArrayLength(env, a) == 20);
44779         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
44780         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
44781         *ret_copy = Fallback_script_hash(a_ref);
44782         int64_t ret_ref = (uintptr_t)ret_copy;
44783         return ret_ref;
44784 }
44785
44786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
44787         LDKFallback* o_conv = (LDKFallback*)o;
44788         int64_t ret_conv = Fallback_hash(o_conv);
44789         return ret_conv;
44790 }
44791
44792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44793         LDKFallback* a_conv = (LDKFallback*)a;
44794         LDKFallback* b_conv = (LDKFallback*)b;
44795         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
44796         return ret_conv;
44797 }
44798
44799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44800         LDKInvoiceSignature this_obj_conv;
44801         this_obj_conv.inner = (void*)(this_obj & (~1));
44802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44804         InvoiceSignature_free(this_obj_conv);
44805 }
44806
44807 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
44808         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
44809 int64_t ret_ref = 0;
44810 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44811 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44812 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44813 ret_ref = (uintptr_t)ret_var.inner;
44814 if (ret_var.is_owned) {
44815         ret_ref |= 1;
44816 }
44817         return ret_ref;
44818 }
44819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44820         LDKInvoiceSignature arg_conv;
44821         arg_conv.inner = (void*)(arg & (~1));
44822         arg_conv.is_owned = false;
44823         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44824         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
44825         return ret_conv;
44826 }
44827
44828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44829         LDKInvoiceSignature orig_conv;
44830         orig_conv.inner = (void*)(orig & (~1));
44831         orig_conv.is_owned = false;
44832         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44833         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
44834         int64_t ret_ref = 0;
44835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44838         ret_ref = (uintptr_t)ret_var.inner;
44839         if (ret_var.is_owned) {
44840                 ret_ref |= 1;
44841         }
44842         return ret_ref;
44843 }
44844
44845 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44846         LDKInvoiceSignature a_conv;
44847         a_conv.inner = (void*)(a & (~1));
44848         a_conv.is_owned = false;
44849         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44850         LDKInvoiceSignature b_conv;
44851         b_conv.inner = (void*)(b & (~1));
44852         b_conv.is_owned = false;
44853         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44854         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
44855         return ret_conv;
44856 }
44857
44858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44859         LDKPrivateRoute this_obj_conv;
44860         this_obj_conv.inner = (void*)(this_obj & (~1));
44861         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
44862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44863         PrivateRoute_free(this_obj_conv);
44864 }
44865
44866 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
44867         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
44868 int64_t ret_ref = 0;
44869 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44870 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44871 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44872 ret_ref = (uintptr_t)ret_var.inner;
44873 if (ret_var.is_owned) {
44874         ret_ref |= 1;
44875 }
44876         return ret_ref;
44877 }
44878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44879         LDKPrivateRoute arg_conv;
44880         arg_conv.inner = (void*)(arg & (~1));
44881         arg_conv.is_owned = false;
44882         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44883         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
44884         return ret_conv;
44885 }
44886
44887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44888         LDKPrivateRoute orig_conv;
44889         orig_conv.inner = (void*)(orig & (~1));
44890         orig_conv.is_owned = false;
44891         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44892         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
44893         int64_t ret_ref = 0;
44894         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44895         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44897         ret_ref = (uintptr_t)ret_var.inner;
44898         if (ret_var.is_owned) {
44899                 ret_ref |= 1;
44900         }
44901         return ret_ref;
44902 }
44903
44904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
44905         LDKPrivateRoute o_conv;
44906         o_conv.inner = (void*)(o & (~1));
44907         o_conv.is_owned = false;
44908         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44909         int64_t ret_conv = PrivateRoute_hash(&o_conv);
44910         return ret_conv;
44911 }
44912
44913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44914         LDKPrivateRoute a_conv;
44915         a_conv.inner = (void*)(a & (~1));
44916         a_conv.is_owned = false;
44917         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44918         LDKPrivateRoute b_conv;
44919         b_conv.inner = (void*)(b & (~1));
44920         b_conv.is_owned = false;
44921         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44922         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
44923         return ret_conv;
44924 }
44925
44926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
44927         LDKSignedRawInvoice this_arg_conv;
44928         this_arg_conv.inner = (void*)(this_arg & (~1));
44929         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
44930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44931         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
44932         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
44933         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
44934         return ((int64_t)ret_conv);
44935 }
44936
44937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
44938         LDKSignedRawInvoice this_arg_conv;
44939         this_arg_conv.inner = (void*)(this_arg & (~1));
44940         this_arg_conv.is_owned = false;
44941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44942         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
44943         int64_t ret_ref = 0;
44944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44947         ret_ref = (uintptr_t)ret_var.inner;
44948         if (ret_var.is_owned) {
44949                 ret_ref |= 1;
44950         }
44951         return ret_ref;
44952 }
44953
44954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
44955         LDKSignedRawInvoice this_arg_conv;
44956         this_arg_conv.inner = (void*)(this_arg & (~1));
44957         this_arg_conv.is_owned = false;
44958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44959         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44960         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
44961         return ret_arr;
44962 }
44963
44964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
44965         LDKSignedRawInvoice this_arg_conv;
44966         this_arg_conv.inner = (void*)(this_arg & (~1));
44967         this_arg_conv.is_owned = false;
44968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44969         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
44970         int64_t ret_ref = 0;
44971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
44972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
44973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44974         ret_ref = (uintptr_t)ret_var.inner;
44975         if (ret_var.is_owned) {
44976                 ret_ref |= 1;
44977         }
44978         return ret_ref;
44979 }
44980
44981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44982         LDKSignedRawInvoice this_arg_conv;
44983         this_arg_conv.inner = (void*)(this_arg & (~1));
44984         this_arg_conv.is_owned = false;
44985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44986         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
44987         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
44988         return (int64_t)ret_conv;
44989 }
44990
44991 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
44992         LDKSignedRawInvoice this_arg_conv;
44993         this_arg_conv.inner = (void*)(this_arg & (~1));
44994         this_arg_conv.is_owned = false;
44995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44996         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
44997         return ret_conv;
44998 }
44999
45000 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
45001         LDKRawInvoice this_arg_conv;
45002         this_arg_conv.inner = (void*)(this_arg & (~1));
45003         this_arg_conv.is_owned = false;
45004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45005         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45006         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
45007         return ret_arr;
45008 }
45009
45010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
45011         LDKRawInvoice this_arg_conv;
45012         this_arg_conv.inner = (void*)(this_arg & (~1));
45013         this_arg_conv.is_owned = false;
45014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45015         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
45016         int64_t ret_ref = 0;
45017         if ((uintptr_t)ret_var.inner > 4096) {
45018                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45019                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45021                 ret_ref = (uintptr_t)ret_var.inner;
45022                 if (ret_var.is_owned) {
45023                         ret_ref |= 1;
45024                 }
45025         }
45026         return ret_ref;
45027 }
45028
45029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
45030         LDKRawInvoice this_arg_conv;
45031         this_arg_conv.inner = (void*)(this_arg & (~1));
45032         this_arg_conv.is_owned = false;
45033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45034         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
45035         int64_t ret_ref = 0;
45036         if ((uintptr_t)ret_var.inner > 4096) {
45037                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45038                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45040                 ret_ref = (uintptr_t)ret_var.inner;
45041                 if (ret_var.is_owned) {
45042                         ret_ref |= 1;
45043                 }
45044         }
45045         return ret_ref;
45046 }
45047
45048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45049         LDKRawInvoice this_arg_conv;
45050         this_arg_conv.inner = (void*)(this_arg & (~1));
45051         this_arg_conv.is_owned = false;
45052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45053         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
45054         int64_t ret_ref = 0;
45055         if ((uintptr_t)ret_var.inner > 4096) {
45056                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45057                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45059                 ret_ref = (uintptr_t)ret_var.inner;
45060                 if (ret_var.is_owned) {
45061                         ret_ref |= 1;
45062                 }
45063         }
45064         return ret_ref;
45065 }
45066
45067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
45068         LDKRawInvoice this_arg_conv;
45069         this_arg_conv.inner = (void*)(this_arg & (~1));
45070         this_arg_conv.is_owned = false;
45071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45072         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
45073         int64_t ret_ref = 0;
45074         if ((uintptr_t)ret_var.inner > 4096) {
45075                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45076                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45078                 ret_ref = (uintptr_t)ret_var.inner;
45079                 if (ret_var.is_owned) {
45080                         ret_ref |= 1;
45081                 }
45082         }
45083         return ret_ref;
45084 }
45085
45086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
45087         LDKRawInvoice this_arg_conv;
45088         this_arg_conv.inner = (void*)(this_arg & (~1));
45089         this_arg_conv.is_owned = false;
45090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45091         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
45092         int64_t ret_ref = 0;
45093         if ((uintptr_t)ret_var.inner > 4096) {
45094                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45095                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45097                 ret_ref = (uintptr_t)ret_var.inner;
45098                 if (ret_var.is_owned) {
45099                         ret_ref |= 1;
45100                 }
45101         }
45102         return ret_ref;
45103 }
45104
45105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
45106         LDKRawInvoice this_arg_conv;
45107         this_arg_conv.inner = (void*)(this_arg & (~1));
45108         this_arg_conv.is_owned = false;
45109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45110         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
45111         int64_t ret_ref = 0;
45112         if ((uintptr_t)ret_var.inner > 4096) {
45113                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45114                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45116                 ret_ref = (uintptr_t)ret_var.inner;
45117                 if (ret_var.is_owned) {
45118                         ret_ref |= 1;
45119                 }
45120         }
45121         return ret_ref;
45122 }
45123
45124 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45125         LDKRawInvoice this_arg_conv;
45126         this_arg_conv.inner = (void*)(this_arg & (~1));
45127         this_arg_conv.is_owned = false;
45128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45129         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45130         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
45131         return ret_arr;
45132 }
45133
45134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
45135         LDKRawInvoice this_arg_conv;
45136         this_arg_conv.inner = (void*)(this_arg & (~1));
45137         this_arg_conv.is_owned = false;
45138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45139         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
45140         int64_t ret_ref = 0;
45141         if ((uintptr_t)ret_var.inner > 4096) {
45142                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45143                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45145                 ret_ref = (uintptr_t)ret_var.inner;
45146                 if (ret_var.is_owned) {
45147                         ret_ref |= 1;
45148                 }
45149         }
45150         return ret_ref;
45151 }
45152
45153 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
45154         LDKRawInvoice this_arg_conv;
45155         this_arg_conv.inner = (void*)(this_arg & (~1));
45156         this_arg_conv.is_owned = false;
45157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45158         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
45159         int64_tArray ret_arr = NULL;
45160         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45161         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45162         for (size_t o = 0; o < ret_var.datalen; o++) {
45163                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
45164                 int64_t ret_conv_14_ref = 0;
45165                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45166                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45167                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45168                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45169                 if (ret_conv_14_var.is_owned) {
45170                         ret_conv_14_ref |= 1;
45171                 }
45172                 ret_arr_ptr[o] = ret_conv_14_ref;
45173         }
45174         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45175         FREE(ret_var.data);
45176         return ret_arr;
45177 }
45178
45179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
45180         LDKRawInvoice this_arg_conv;
45181         this_arg_conv.inner = (void*)(this_arg & (~1));
45182         this_arg_conv.is_owned = false;
45183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45184         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45185         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
45186         int64_t ret_ref = (uintptr_t)ret_copy;
45187         return ret_ref;
45188 }
45189
45190 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
45191         LDKRawInvoice this_arg_conv;
45192         this_arg_conv.inner = (void*)(this_arg & (~1));
45193         this_arg_conv.is_owned = false;
45194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45195         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
45196         return ret_conv;
45197 }
45198
45199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
45200         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45201         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
45202         return (int64_t)ret_conv;
45203 }
45204
45205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
45206         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45207         *ret_conv = PositiveTimestamp_from_system_time(time);
45208         return (int64_t)ret_conv;
45209 }
45210
45211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
45212         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
45213         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
45214         return (int64_t)ret_conv;
45215 }
45216
45217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
45218         LDKPositiveTimestamp this_arg_conv;
45219         this_arg_conv.inner = (void*)(this_arg & (~1));
45220         this_arg_conv.is_owned = false;
45221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45222         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
45223         return ret_conv;
45224 }
45225
45226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
45227         LDKPositiveTimestamp this_arg_conv;
45228         this_arg_conv.inner = (void*)(this_arg & (~1));
45229         this_arg_conv.is_owned = false;
45230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45231         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
45232         return ret_conv;
45233 }
45234
45235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
45236         LDKPositiveTimestamp this_arg_conv;
45237         this_arg_conv.inner = (void*)(this_arg & (~1));
45238         this_arg_conv.is_owned = false;
45239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45240         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
45241         return ret_conv;
45242 }
45243
45244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
45245         LDKInvoice this_arg_conv;
45246         this_arg_conv.inner = (void*)(this_arg & (~1));
45247         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45249         this_arg_conv = Invoice_clone(&this_arg_conv);
45250         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
45251         int64_t ret_ref = 0;
45252         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45253         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45255         ret_ref = (uintptr_t)ret_var.inner;
45256         if (ret_var.is_owned) {
45257                 ret_ref |= 1;
45258         }
45259         return ret_ref;
45260 }
45261
45262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
45263         LDKInvoice this_arg_conv;
45264         this_arg_conv.inner = (void*)(this_arg & (~1));
45265         this_arg_conv.is_owned = false;
45266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45267         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
45268         *ret_conv = Invoice_check_signature(&this_arg_conv);
45269         return (int64_t)ret_conv;
45270 }
45271
45272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
45273         LDKSignedRawInvoice signed_invoice_conv;
45274         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
45275         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
45276         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
45277         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
45278         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
45279         *ret_conv = Invoice_from_signed(signed_invoice_conv);
45280         return (int64_t)ret_conv;
45281 }
45282
45283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
45284         LDKInvoice this_arg_conv;
45285         this_arg_conv.inner = (void*)(this_arg & (~1));
45286         this_arg_conv.is_owned = false;
45287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45288         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
45289         return ret_conv;
45290 }
45291
45292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
45293         LDKInvoice this_arg_conv;
45294         this_arg_conv.inner = (void*)(this_arg & (~1));
45295         this_arg_conv.is_owned = false;
45296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45297         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
45298         return ret_conv;
45299 }
45300
45301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
45302         LDKInvoice this_arg_conv;
45303         this_arg_conv.inner = (void*)(this_arg & (~1));
45304         this_arg_conv.is_owned = false;
45305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45306         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45307         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
45308         return ret_arr;
45309 }
45310
45311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45312         LDKInvoice this_arg_conv;
45313         this_arg_conv.inner = (void*)(this_arg & (~1));
45314         this_arg_conv.is_owned = false;
45315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45316         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45317         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
45318         return ret_arr;
45319 }
45320
45321 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
45322         LDKInvoice this_arg_conv;
45323         this_arg_conv.inner = (void*)(this_arg & (~1));
45324         this_arg_conv.is_owned = false;
45325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45326         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
45327         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
45328         return ret_arr;
45329 }
45330
45331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
45332         LDKInvoice this_arg_conv;
45333         this_arg_conv.inner = (void*)(this_arg & (~1));
45334         this_arg_conv.is_owned = false;
45335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45336         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
45337         int64_t ret_ref = 0;
45338         if ((uintptr_t)ret_var.inner > 4096) {
45339                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45340                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45342                 ret_ref = (uintptr_t)ret_var.inner;
45343                 if (ret_var.is_owned) {
45344                         ret_ref |= 1;
45345                 }
45346         }
45347         return ret_ref;
45348 }
45349
45350 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
45351         LDKInvoice this_arg_conv;
45352         this_arg_conv.inner = (void*)(this_arg & (~1));
45353         this_arg_conv.is_owned = false;
45354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45355         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45356         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
45357         return ret_arr;
45358 }
45359
45360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
45361         LDKInvoice this_arg_conv;
45362         this_arg_conv.inner = (void*)(this_arg & (~1));
45363         this_arg_conv.is_owned = false;
45364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45365         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
45366         return ret_conv;
45367 }
45368
45369 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
45370         LDKInvoice this_arg_conv;
45371         this_arg_conv.inner = (void*)(this_arg & (~1));
45372         this_arg_conv.is_owned = false;
45373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45374         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
45375         return ret_conv;
45376 }
45377
45378 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
45379         LDKInvoice this_arg_conv;
45380         this_arg_conv.inner = (void*)(this_arg & (~1));
45381         this_arg_conv.is_owned = false;
45382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45383         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
45384         return ret_conv;
45385 }
45386
45387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
45388         LDKInvoice this_arg_conv;
45389         this_arg_conv.inner = (void*)(this_arg & (~1));
45390         this_arg_conv.is_owned = false;
45391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45392         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
45393         return ret_conv;
45394 }
45395
45396 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
45397         LDKInvoice this_arg_conv;
45398         this_arg_conv.inner = (void*)(this_arg & (~1));
45399         this_arg_conv.is_owned = false;
45400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45401         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
45402         int64_tArray ret_arr = NULL;
45403         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45404         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45405         for (size_t o = 0; o < ret_var.datalen; o++) {
45406                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
45407                 int64_t ret_conv_14_ref = 0;
45408                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45409                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45410                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
45411                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
45412                 if (ret_conv_14_var.is_owned) {
45413                         ret_conv_14_ref |= 1;
45414                 }
45415                 ret_arr_ptr[o] = ret_conv_14_ref;
45416         }
45417         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45418         FREE(ret_var.data);
45419         return ret_arr;
45420 }
45421
45422 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
45423         LDKInvoice this_arg_conv;
45424         this_arg_conv.inner = (void*)(this_arg & (~1));
45425         this_arg_conv.is_owned = false;
45426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45427         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
45428         int64_tArray ret_arr = NULL;
45429         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45430         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45431         for (size_t l = 0; l < ret_var.datalen; l++) {
45432                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
45433                 int64_t ret_conv_11_ref = 0;
45434                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45435                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45436                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
45437                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
45438                 if (ret_conv_11_var.is_owned) {
45439                         ret_conv_11_ref |= 1;
45440                 }
45441                 ret_arr_ptr[l] = ret_conv_11_ref;
45442         }
45443         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45444         FREE(ret_var.data);
45445         return ret_arr;
45446 }
45447
45448 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
45449         LDKInvoice this_arg_conv;
45450         this_arg_conv.inner = (void*)(this_arg & (~1));
45451         this_arg_conv.is_owned = false;
45452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45453         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
45454         return ret_conv;
45455 }
45456
45457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
45458         LDKInvoice this_arg_conv;
45459         this_arg_conv.inner = (void*)(this_arg & (~1));
45460         this_arg_conv.is_owned = false;
45461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45462         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
45463         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
45464         int64_t ret_ref = (uintptr_t)ret_copy;
45465         return ret_ref;
45466 }
45467
45468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
45469         LDKStr description_conv = java_to_owned_str(env, description);
45470         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
45471         *ret_conv = Description_new(description_conv);
45472         return (int64_t)ret_conv;
45473 }
45474
45475 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
45476         LDKDescription this_arg_conv;
45477         this_arg_conv.inner = (void*)(this_arg & (~1));
45478         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45480         this_arg_conv = Description_clone(&this_arg_conv);
45481         LDKStr ret_str = Description_into_inner(this_arg_conv);
45482         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45483         Str_free(ret_str);
45484         return ret_conv;
45485 }
45486
45487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
45488         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
45489         int64_t ret_ref = 0;
45490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45493         ret_ref = (uintptr_t)ret_var.inner;
45494         if (ret_var.is_owned) {
45495                 ret_ref |= 1;
45496         }
45497         return ret_ref;
45498 }
45499
45500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
45501         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
45502         int64_t ret_ref = 0;
45503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45506         ret_ref = (uintptr_t)ret_var.inner;
45507         if (ret_var.is_owned) {
45508                 ret_ref |= 1;
45509         }
45510         return ret_ref;
45511 }
45512
45513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
45514         LDKExpiryTime this_arg_conv;
45515         this_arg_conv.inner = (void*)(this_arg & (~1));
45516         this_arg_conv.is_owned = false;
45517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45518         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
45519         return ret_conv;
45520 }
45521
45522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
45523         LDKExpiryTime this_arg_conv;
45524         this_arg_conv.inner = (void*)(this_arg & (~1));
45525         this_arg_conv.is_owned = false;
45526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45527         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
45528         return ret_conv;
45529 }
45530
45531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
45532         LDKRouteHint hops_conv;
45533         hops_conv.inner = (void*)(hops & (~1));
45534         hops_conv.is_owned = (hops & 1) || (hops == 0);
45535         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
45536         hops_conv = RouteHint_clone(&hops_conv);
45537         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
45538         *ret_conv = PrivateRoute_new(hops_conv);
45539         return (int64_t)ret_conv;
45540 }
45541
45542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
45543         LDKPrivateRoute this_arg_conv;
45544         this_arg_conv.inner = (void*)(this_arg & (~1));
45545         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
45546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45547         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
45548         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
45549         int64_t ret_ref = 0;
45550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45553         ret_ref = (uintptr_t)ret_var.inner;
45554         if (ret_var.is_owned) {
45555                 ret_ref |= 1;
45556         }
45557         return ret_ref;
45558 }
45559
45560 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45561         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
45562         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
45563         return ret_conv;
45564 }
45565
45566 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
45567         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
45568         return ret_conv;
45569 }
45570
45571 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
45572         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
45573         return ret_conv;
45574 }
45575
45576 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
45577         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
45578         return ret_conv;
45579 }
45580
45581 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
45582         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
45583         return ret_conv;
45584 }
45585
45586 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
45587         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
45588         return ret_conv;
45589 }
45590
45591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45592         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
45593         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
45594         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
45595         return ret_conv;
45596 }
45597
45598 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45599         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
45600         LDKStr ret_str = CreationError_to_str(o_conv);
45601         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45602         Str_free(ret_str);
45603         return ret_conv;
45604 }
45605
45606 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45607         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
45608         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
45609         return ret_conv;
45610 }
45611
45612 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
45613         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
45614         return ret_conv;
45615 }
45616
45617 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
45618         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
45619         return ret_conv;
45620 }
45621
45622 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
45623         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
45624         return ret_conv;
45625 }
45626
45627 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
45628         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
45629         return ret_conv;
45630 }
45631
45632 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
45633         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
45634         return ret_conv;
45635 }
45636
45637 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
45638         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
45639         return ret_conv;
45640 }
45641
45642 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
45643         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
45644         return ret_conv;
45645 }
45646
45647 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
45648         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
45649         return ret_conv;
45650 }
45651
45652 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
45653         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
45654         return ret_conv;
45655 }
45656
45657 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
45658         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
45659         return ret_conv;
45660 }
45661
45662 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45663         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
45664         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
45665         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
45666         return ret_conv;
45667 }
45668
45669 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45670         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
45671         LDKStr ret_str = SemanticError_to_str(o_conv);
45672         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45673         Str_free(ret_str);
45674         return ret_conv;
45675 }
45676
45677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45678         if ((this_ptr & 1) != 0) return;
45679         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45680         CHECK_ACCESS(this_ptr_ptr);
45681         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
45682         FREE((void*)this_ptr);
45683         SignOrCreationError_free(this_ptr_conv);
45684 }
45685
45686 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
45687         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45688         *ret_copy = SignOrCreationError_clone(arg);
45689 int64_t ret_ref = (uintptr_t)ret_copy;
45690         return ret_ref;
45691 }
45692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45693         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
45694         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
45695         return ret_conv;
45696 }
45697
45698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45699         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
45700         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45701         *ret_copy = SignOrCreationError_clone(orig_conv);
45702         int64_t ret_ref = (uintptr_t)ret_copy;
45703         return ret_ref;
45704 }
45705
45706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
45707         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45708         *ret_copy = SignOrCreationError_sign_error();
45709         int64_t ret_ref = (uintptr_t)ret_copy;
45710         return ret_ref;
45711 }
45712
45713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
45714         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
45715         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
45716         *ret_copy = SignOrCreationError_creation_error(a_conv);
45717         int64_t ret_ref = (uintptr_t)ret_copy;
45718         return ret_ref;
45719 }
45720
45721 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45722         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
45723         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
45724         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
45725         return ret_conv;
45726 }
45727
45728 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
45729         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
45730         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
45731         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
45732         Str_free(ret_str);
45733         return ret_conv;
45734 }
45735
45736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45737         LDKInvoicePayer this_obj_conv;
45738         this_obj_conv.inner = (void*)(this_obj & (~1));
45739         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45741         InvoicePayer_free(this_obj_conv);
45742 }
45743
45744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45745         if ((this_ptr & 1) != 0) return;
45746         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45747         CHECK_ACCESS(this_ptr_ptr);
45748         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
45749         FREE((void*)this_ptr);
45750         Payer_free(this_ptr_conv);
45751 }
45752
45753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45754         if ((this_ptr & 1) != 0) return;
45755         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45756         CHECK_ACCESS(this_ptr_ptr);
45757         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
45758         FREE((void*)this_ptr);
45759         Router_free(this_ptr_conv);
45760 }
45761
45762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45763         LDKRetryAttempts this_obj_conv;
45764         this_obj_conv.inner = (void*)(this_obj & (~1));
45765         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
45766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45767         RetryAttempts_free(this_obj_conv);
45768 }
45769
45770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
45771         LDKRetryAttempts this_ptr_conv;
45772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45773         this_ptr_conv.is_owned = false;
45774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45775         int64_t ret_conv = RetryAttempts_get_a(&this_ptr_conv);
45776         return ret_conv;
45777 }
45778
45779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45780         LDKRetryAttempts this_ptr_conv;
45781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
45782         this_ptr_conv.is_owned = false;
45783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45784         RetryAttempts_set_a(&this_ptr_conv, val);
45785 }
45786
45787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
45788         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
45789         int64_t ret_ref = 0;
45790         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45791         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45793         ret_ref = (uintptr_t)ret_var.inner;
45794         if (ret_var.is_owned) {
45795                 ret_ref |= 1;
45796         }
45797         return ret_ref;
45798 }
45799
45800 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
45801         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
45802 int64_t ret_ref = 0;
45803 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45804 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45805 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45806 ret_ref = (uintptr_t)ret_var.inner;
45807 if (ret_var.is_owned) {
45808         ret_ref |= 1;
45809 }
45810         return ret_ref;
45811 }
45812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45813         LDKRetryAttempts arg_conv;
45814         arg_conv.inner = (void*)(arg & (~1));
45815         arg_conv.is_owned = false;
45816         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45817         int64_t ret_conv = RetryAttempts_clone_ptr(&arg_conv);
45818         return ret_conv;
45819 }
45820
45821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45822         LDKRetryAttempts orig_conv;
45823         orig_conv.inner = (void*)(orig & (~1));
45824         orig_conv.is_owned = false;
45825         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45826         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
45827         int64_t ret_ref = 0;
45828         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45829         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45831         ret_ref = (uintptr_t)ret_var.inner;
45832         if (ret_var.is_owned) {
45833                 ret_ref |= 1;
45834         }
45835         return ret_ref;
45836 }
45837
45838 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45839         LDKRetryAttempts a_conv;
45840         a_conv.inner = (void*)(a & (~1));
45841         a_conv.is_owned = false;
45842         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45843         LDKRetryAttempts b_conv;
45844         b_conv.inner = (void*)(b & (~1));
45845         b_conv.is_owned = false;
45846         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45847         jboolean ret_conv = RetryAttempts_eq(&a_conv, &b_conv);
45848         return ret_conv;
45849 }
45850
45851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
45852         LDKRetryAttempts o_conv;
45853         o_conv.inner = (void*)(o & (~1));
45854         o_conv.is_owned = false;
45855         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45856         int64_t ret_conv = RetryAttempts_hash(&o_conv);
45857         return ret_conv;
45858 }
45859
45860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45861         if ((this_ptr & 1) != 0) return;
45862         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
45863         CHECK_ACCESS(this_ptr_ptr);
45864         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
45865         FREE((void*)this_ptr);
45866         PaymentError_free(this_ptr_conv);
45867 }
45868
45869 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
45870         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45871         *ret_copy = PaymentError_clone(arg);
45872 int64_t ret_ref = (uintptr_t)ret_copy;
45873         return ret_ref;
45874 }
45875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45876         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
45877         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
45878         return ret_conv;
45879 }
45880
45881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45882         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
45883         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45884         *ret_copy = PaymentError_clone(orig_conv);
45885         int64_t ret_ref = (uintptr_t)ret_copy;
45886         return ret_ref;
45887 }
45888
45889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
45890         LDKStr a_conv = java_to_owned_str(env, a);
45891         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45892         *ret_copy = PaymentError_invoice(a_conv);
45893         int64_t ret_ref = (uintptr_t)ret_copy;
45894         return ret_ref;
45895 }
45896
45897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
45898         LDKLightningError a_conv;
45899         a_conv.inner = (void*)(a & (~1));
45900         a_conv.is_owned = (a & 1) || (a == 0);
45901         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45902         a_conv = LightningError_clone(&a_conv);
45903         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45904         *ret_copy = PaymentError_routing(a_conv);
45905         int64_t ret_ref = (uintptr_t)ret_copy;
45906         return ret_ref;
45907 }
45908
45909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
45910         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
45911         CHECK_ACCESS(a_ptr);
45912         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
45913         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
45914         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
45915         *ret_copy = PaymentError_sending(a_conv);
45916         int64_t ret_ref = (uintptr_t)ret_copy;
45917         return ret_ref;
45918 }
45919
45920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t scorer, int64_t logger, int64_t event_handler, int64_t retry_attempts) {
45921         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
45922         CHECK_ACCESS(payer_ptr);
45923         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
45924         if (payer_conv.free == LDKPayer_JCalls_free) {
45925                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45926                 LDKPayer_JCalls_cloned(&payer_conv);
45927         }
45928         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
45929         CHECK_ACCESS(router_ptr);
45930         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
45931         if (router_conv.free == LDKRouter_JCalls_free) {
45932                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45933                 LDKRouter_JCalls_cloned(&router_conv);
45934         }
45935         LDKMultiThreadedLockableScore scorer_conv;
45936         scorer_conv.inner = (void*)(scorer & (~1));
45937         scorer_conv.is_owned = false;
45938         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
45939         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
45940         CHECK_ACCESS(logger_ptr);
45941         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
45942         if (logger_conv.free == LDKLogger_JCalls_free) {
45943                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45944                 LDKLogger_JCalls_cloned(&logger_conv);
45945         }
45946         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
45947         CHECK_ACCESS(event_handler_ptr);
45948         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
45949         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
45950                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45951                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
45952         }
45953         LDKRetryAttempts retry_attempts_conv;
45954         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
45955         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
45956         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
45957         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
45958         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
45959         int64_t ret_ref = 0;
45960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
45961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
45962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45963         ret_ref = (uintptr_t)ret_var.inner;
45964         if (ret_var.is_owned) {
45965                 ret_ref |= 1;
45966         }
45967         return ret_ref;
45968 }
45969
45970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
45971         LDKInvoicePayer this_arg_conv;
45972         this_arg_conv.inner = (void*)(this_arg & (~1));
45973         this_arg_conv.is_owned = false;
45974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45975         LDKInvoice invoice_conv;
45976         invoice_conv.inner = (void*)(invoice & (~1));
45977         invoice_conv.is_owned = false;
45978         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45979         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45980         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
45981         return (int64_t)ret_conv;
45982 }
45983
45984 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) {
45985         LDKInvoicePayer this_arg_conv;
45986         this_arg_conv.inner = (void*)(this_arg & (~1));
45987         this_arg_conv.is_owned = false;
45988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45989         LDKInvoice invoice_conv;
45990         invoice_conv.inner = (void*)(invoice & (~1));
45991         invoice_conv.is_owned = false;
45992         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
45993         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
45994         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
45995         return (int64_t)ret_conv;
45996 }
45997
45998 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) {
45999         LDKInvoicePayer this_arg_conv;
46000         this_arg_conv.inner = (void*)(this_arg & (~1));
46001         this_arg_conv.is_owned = false;
46002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46003         LDKPublicKey pubkey_ref;
46004         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
46005         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
46006         LDKThirtyTwoBytes payment_preimage_ref;
46007         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
46008         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
46009         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
46010         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
46011         return (int64_t)ret_conv;
46012 }
46013
46014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
46015         LDKInvoicePayer this_arg_conv;
46016         this_arg_conv.inner = (void*)(this_arg & (~1));
46017         this_arg_conv.is_owned = false;
46018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46019         unsigned char payment_hash_arr[32];
46020         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
46021         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
46022         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
46023         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
46024 }
46025
46026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
46027         LDKInvoicePayer this_arg_conv;
46028         this_arg_conv.inner = (void*)(this_arg & (~1));
46029         this_arg_conv.is_owned = false;
46030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46031         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
46032         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
46033         return (int64_t)ret_ret;
46034 }
46035
46036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice(JNIEnv *env, jclass clz, int64_t amt_msat, jstring description, int8_tArray payment_hash, int8_tArray payment_secret, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
46037         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46038         CHECK_ACCESS(amt_msat_ptr);
46039         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46040         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46041         LDKStr description_conv = java_to_owned_str(env, description);
46042         LDKThirtyTwoBytes payment_hash_ref;
46043         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
46044         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
46045         LDKThirtyTwoBytes payment_secret_ref;
46046         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
46047         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
46048         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
46049         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
46050         if (phantom_route_hints_constr.datalen > 0)
46051                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
46052         else
46053                 phantom_route_hints_constr.data = NULL;
46054         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
46055         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
46056                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
46057                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
46058                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
46059                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
46060                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
46061                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
46062                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
46063         }
46064         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
46065         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46066         CHECK_ACCESS(keys_manager_ptr);
46067         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46068         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46069                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46070                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46071         }
46072         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46073         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46074         *ret_conv = create_phantom_invoice(amt_msat_conv, description_conv, payment_hash_ref, payment_secret_ref, phantom_route_hints_constr, keys_manager_conv, network_conv);
46075         return (int64_t)ret_conv;
46076 }
46077
46078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t amt_msat, int64_t description_hash, int8_tArray payment_hash, int8_tArray payment_secret, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
46079         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46080         CHECK_ACCESS(amt_msat_ptr);
46081         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46082         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46083         LDKSha256 description_hash_conv;
46084         description_hash_conv.inner = (void*)(description_hash & (~1));
46085         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
46086         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
46087         description_hash_conv = Sha256_clone(&description_hash_conv);
46088         LDKThirtyTwoBytes payment_hash_ref;
46089         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
46090         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
46091         LDKThirtyTwoBytes payment_secret_ref;
46092         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
46093         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
46094         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
46095         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
46096         if (phantom_route_hints_constr.datalen > 0)
46097                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
46098         else
46099                 phantom_route_hints_constr.data = NULL;
46100         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
46101         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
46102                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
46103                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
46104                 phantom_route_hints_conv_19_conv.inner = (void*)(phantom_route_hints_conv_19 & (~1));
46105                 phantom_route_hints_conv_19_conv.is_owned = (phantom_route_hints_conv_19 & 1) || (phantom_route_hints_conv_19 == 0);
46106                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
46107                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
46108                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
46109         }
46110         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
46111         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46112         CHECK_ACCESS(keys_manager_ptr);
46113         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46114         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46115                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46116                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46117         }
46118         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46119         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46120         *ret_conv = create_phantom_invoice_with_description_hash(amt_msat_conv, description_hash_conv, payment_hash_ref, payment_secret_ref, phantom_route_hints_constr, keys_manager_conv, network_conv);
46121         return (int64_t)ret_conv;
46122 }
46123
46124 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) {
46125         LDKChannelManager channelmanager_conv;
46126         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46127         channelmanager_conv.is_owned = false;
46128         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46129         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46130         CHECK_ACCESS(keys_manager_ptr);
46131         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46132         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46133                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46134                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46135         }
46136         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46137         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46138         CHECK_ACCESS(amt_msat_ptr);
46139         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46140         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46141         LDKStr description_conv = java_to_owned_str(env, description);
46142         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46143         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
46144         return (int64_t)ret_conv;
46145 }
46146
46147 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) {
46148         LDKChannelManager channelmanager_conv;
46149         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46150         channelmanager_conv.is_owned = false;
46151         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46152         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46153         CHECK_ACCESS(keys_manager_ptr);
46154         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46155         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46156                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46157                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46158         }
46159         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46160         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46161         CHECK_ACCESS(amt_msat_ptr);
46162         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46163         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46164         LDKSha256 description_hash_conv;
46165         description_hash_conv.inner = (void*)(description_hash & (~1));
46166         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
46167         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
46168         description_hash_conv = Sha256_clone(&description_hash_conv);
46169         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46170         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv);
46171         return (int64_t)ret_conv;
46172 }
46173
46174 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) {
46175         LDKChannelManager channelmanager_conv;
46176         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46177         channelmanager_conv.is_owned = false;
46178         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46179         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46180         CHECK_ACCESS(keys_manager_ptr);
46181         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46182         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46183                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46184                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46185         }
46186         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46187         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46188         CHECK_ACCESS(amt_msat_ptr);
46189         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46190         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46191         LDKSha256 description_hash_conv;
46192         description_hash_conv.inner = (void*)(description_hash & (~1));
46193         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
46194         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
46195         description_hash_conv = Sha256_clone(&description_hash_conv);
46196         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46197         *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);
46198         return (int64_t)ret_conv;
46199 }
46200
46201 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) {
46202         LDKChannelManager channelmanager_conv;
46203         channelmanager_conv.inner = (void*)(channelmanager & (~1));
46204         channelmanager_conv.is_owned = false;
46205         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
46206         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
46207         CHECK_ACCESS(keys_manager_ptr);
46208         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
46209         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
46210                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46211                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
46212         }
46213         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
46214         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
46215         CHECK_ACCESS(amt_msat_ptr);
46216         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
46217         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
46218         LDKStr description_conv = java_to_owned_str(env, description);
46219         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
46220         *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);
46221         return (int64_t)ret_conv;
46222 }
46223
46224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46225         LDKDefaultRouter this_obj_conv;
46226         this_obj_conv.inner = (void*)(this_obj & (~1));
46227         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
46228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46229         DefaultRouter_free(this_obj_conv);
46230 }
46231
46232 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) {
46233         LDKNetworkGraph network_graph_conv;
46234         network_graph_conv.inner = (void*)(network_graph & (~1));
46235         network_graph_conv.is_owned = false;
46236         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46237         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
46238         CHECK_ACCESS(logger_ptr);
46239         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46240         if (logger_conv.free == LDKLogger_JCalls_free) {
46241                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46242                 LDKLogger_JCalls_cloned(&logger_conv);
46243         }
46244         LDKThirtyTwoBytes random_seed_bytes_ref;
46245         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46246         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
46247         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
46248         int64_t ret_ref = 0;
46249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
46250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
46251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46252         ret_ref = (uintptr_t)ret_var.inner;
46253         if (ret_var.is_owned) {
46254                 ret_ref |= 1;
46255         }
46256         return ret_ref;
46257 }
46258
46259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
46260         LDKDefaultRouter this_arg_conv;
46261         this_arg_conv.inner = (void*)(this_arg & (~1));
46262         this_arg_conv.is_owned = false;
46263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46264         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
46265         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
46266         return (int64_t)ret_ret;
46267 }
46268
46269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
46270         LDKChannelManager this_arg_conv;
46271         this_arg_conv.inner = (void*)(this_arg & (~1));
46272         this_arg_conv.is_owned = false;
46273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46274         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
46275         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
46276         return (int64_t)ret_ret;
46277 }
46278
46279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
46280         LDKStr s_conv = java_to_owned_str(env, s);
46281         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
46282         *ret_conv = SiPrefix_from_str(s_conv);
46283         return (int64_t)ret_conv;
46284 }
46285
46286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
46287         LDKStr s_conv = java_to_owned_str(env, s);
46288         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
46289         *ret_conv = Invoice_from_str(s_conv);
46290         return (int64_t)ret_conv;
46291 }
46292
46293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
46294         LDKStr s_conv = java_to_owned_str(env, s);
46295         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
46296         *ret_conv = SignedRawInvoice_from_str(s_conv);
46297         return (int64_t)ret_conv;
46298 }
46299
46300 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46301         LDKParseError* o_conv = (LDKParseError*)o;
46302         LDKStr ret_str = ParseError_to_str(o_conv);
46303         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46304         Str_free(ret_str);
46305         return ret_conv;
46306 }
46307
46308 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46309         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
46310         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
46311         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46312         Str_free(ret_str);
46313         return ret_conv;
46314 }
46315
46316 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46317         LDKInvoice o_conv;
46318         o_conv.inner = (void*)(o & (~1));
46319         o_conv.is_owned = false;
46320         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46321         LDKStr ret_str = Invoice_to_str(&o_conv);
46322         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46323         Str_free(ret_str);
46324         return ret_conv;
46325 }
46326
46327 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46328         LDKSignedRawInvoice o_conv;
46329         o_conv.inner = (void*)(o & (~1));
46330         o_conv.is_owned = false;
46331         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46332         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
46333         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46334         Str_free(ret_str);
46335         return ret_conv;
46336 }
46337
46338 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46339         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
46340         LDKStr ret_str = Currency_to_str(o_conv);
46341         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46342         Str_free(ret_str);
46343         return ret_conv;
46344 }
46345
46346 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
46347         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
46348         LDKStr ret_str = SiPrefix_to_str(o_conv);
46349         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
46350         Str_free(ret_str);
46351         return ret_conv;
46352 }
46353